@Override public Text text(final int line, final int col, final String str) { Text t = new Text(); t.value = str; return t; }
@Override public final String getTextStringValue(Object text) { // CDATA is a subclass of Text return ((Text)text).getText(); }
/** * This returns the textual content with all surrounding whitespace * removed and internal whitespace normalized to a single space. If * only whitespace exists, the empty string is returned. * * @return normalized text content or empty string */ public String getTextNormalize() { return normalizeString(getText()); }
/** * Returns the content of an element as string. The element itself * is ignored. * * @param e the element to get the content from * @return the content as string */ protected String getContent(Element e) throws IOException { XMLOutputter out = new XMLOutputter(); StringWriter writer = new StringWriter(); for (Content child : e.getContent()) { if (child instanceof Element) { out.output((Element) child, writer); } else if (child instanceof Text) { Text t = (Text) child; String trimmedText = t.getTextTrim(); if (!"".equals(trimmedText)) { Text newText = new Text(trimmedText); out.output(newText, writer); } } } return writer.toString(); }
switch (bufferType) { case Float: { final String normalizedText = Text.normalizeString(text); if (normalizedText.length() == 0) { return new Text(""); return new Text(""); final String normalizedText = Text.normalizeString(text); if (normalizedText.length() == 0) { return new Text(""); return new Text(""); final String normalizedText = Text.normalizeString(text); if (normalizedText.length() == 0) { return new Text(""); return new Text(""); final String normalizedText = Text.normalizeString(text); if (normalizedText.length() == 0) { return new Text(""); return new Text(""); return new Text(Text.normalizeString(text));
private IString getString(boolean trim, Text text) throws Skip { if (trim) { java.lang.String s = text.getTextTrim(); if ("".equals(s)) { throw new Skip(); } return vf.string(s); } return vf.string(text.getText()); } }
public MCRJDOMContent transform(MCRContent source) throws IOException { try { Element root = source.asXML().getRootElement().clone(); for (Text text : root.getDescendants(Filters.text())) { text.setText(MCRXMLFunctions.normalizeUnicode(text.getText())); } return new MCRJDOMContent(root); } catch (JDOMException | SAXException ex) { throw new IOException(ex); } } }
private static List<String> extractReferencedClasses(@NotNull Element rootElement) { List<String> referencedClasses = new ArrayList<String>(); Iterator<Content> descendants = rootElement.getDescendants(); while (descendants.hasNext()) { Content next = descendants.next(); if (next instanceof Element) { Element element = (Element) next; if (isInterestingName(element.getName())) { referencedClasses.addAll(extractClasses(element.getTextNormalize())); } for (Attribute attribute : element.getAttributes()) { if (isInterestingName(attribute.getName())) { referencedClasses.addAll(extractClasses(attribute.getValue().trim())); } } } else if (next instanceof Text) { Parent parent = next.getParent(); if (parent instanceof Element) { if (isInterestingName(((Element) parent).getName())) { referencedClasses.addAll(extractClasses(((Text) next).getTextTrim())); } } } } return referencedClasses; }
sb.append( ((Text)el).getValue() );
/** * Returns the textual content of this element with all surrounding * whitespace removed and internal whitespace normalized to a single space. * If no textual value exists for the element, or if only whitespace exists, * the empty string is returned. * * @return normalized text content for this element, or * empty string if none */ public String getTextNormalize() { return Text.normalizeString(getText()); }
/** * This constructor creates a new <code>Text</code> node, with the * supplied string value as it's character content. * * @param str the node's character content. * @throws IllegalDataException if <code>str</code> contains an * illegal character such as a vertical tab (as determined * by {@link org.jdom2.Verifier#checkCharacterData}) */ public Text(String str) { this(CType.Text); setText(str); }
if ( txt.getTextTrim().length() == 0 )
str_value = ((Element) value).getValue(); } else if(value instanceof Text) { str_value = ((Text) value).getValue(); } else if(value instanceof Attribute) { str_value = ((Attribute) value).getValue();
description.setText(Text.normalizeString(pom.getDescription())); pack.addContent(description);
@Override public Text text(final int line, final int col, final String text) { return new Text(text); }