public String getTextStringValue(Object obj) { if ( obj instanceof Text ) { return ((Text)obj).getText(); } if ( obj instanceof CDATA ) { return ((CDATA)obj).getText(); } return ""; }
/** * This will handle printing of <code>{@link Text}</code> strings. * * @param text <code>Text</code> to write. * @param out <code>Writer</code> to use. */ protected void printText(Writer out, Text text) throws IOException { String str=(currentFormat.mode == Format.TextMode.NORMALIZE) ? text.getTextNormalize() : ((currentFormat.mode == Format.TextMode.TRIM) ? text.getText().trim() : text.getText()); out.write(escapeElementEntities(str)); }
public String getElementStringValue(Object obj) { Element elem = (Element) obj; StringBuffer buf = new StringBuffer(); List content = elem.getContent(); Iterator contentIter = content.iterator(); Object each = null; while ( contentIter.hasNext() ) { each = contentIter.next(); if ( each instanceof Text ) { buf.append( ((Text)each).getText() ); } else if ( each instanceof CDATA ) { buf.append( ((CDATA)each).getText() ); } else if ( each instanceof Element ) { buf.append( getElementStringValue( each ) ); } } return buf.toString(); }
/** * This will handle printing of <code>{@link Text}</code> strings. * * @param text <code>Text</code> to write. * @param out <code>Writer</code> to use. */ protected void printText(Writer out, Text text) throws IOException { String str = (currentFormat.mode == Format.TextMode.NORMALIZE) ? text.getTextNormalize() : ((currentFormat.mode == Format.TextMode.TRIM) ? text.getText().trim() : text.getText()); out.write(escapeElementEntities(str)); }
/** * This will append the content of another <code>Text</code> node * to this node. * * @param text Text node to append. */ public void append(Text text) { if (text == null) { return; } value += text.getText(); }
/** * This will handle printing of <code>{@link Text}</code> strings. * * @param text <code>Text</code> to write. * @param out <code>Writer</code> to use. */ protected void printText( Writer out, Text text ) throws IOException { String str = ( currentFormat.mode == Format.TextMode.NORMALIZE ) ? text.getTextNormalize() : ( ( currentFormat.mode == Format.TextMode.TRIM ) ? text.getText().trim() : text.getText() ); out.write( escapeElementEntities( str ) ); }
@Override public String getElementText() throws XMLStreamException { return ((Text)content).getText(); }
@Override public String getElementText() throws XMLStreamException { return ((Text)content).getText(); }
public void init (Object o) { org.jdom.Text text = (org.jdom.Text)o; this.value = text.getText(); }
boolean isBlankLineOrLines(Text content) { if (!keepBlankLines) { return false; } return content.getText().matches("^\\s*?(\\r|\\n)\\s*$"); } }
boolean isBlankLineOrLines(Text content) { if (!keepBlankLines) { return false; } return content.getText().matches("^\\s*?(\\r|\\n)\\s*$"); } }
/** * This returns the textual content with all surrounding whitespace * removed. If only whitespace exists, the empty string is returned. * * @return trimmed text content or empty string */ public String getTextTrim() { return getText().trim(); }
private boolean isSingleNewLine(Text content) { return content.getText().matches("[\\t ]*[\\r]?[\\n]?[\\t ]*"); }
private boolean isSingleNewLine(Text content) { return content.getText().matches("[\\t ]*[\\r]?[\\n]?[\\t ]*"); }
/** * 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()); }
/** * This will append the content of another <code>Text</code> node * to this node. * * @param text Text node to append. */ public void append(final Text text) { // Overrides Text.append(Text) because this needs to check that CDATA // rules are enforced. We could have a separate Verifier check for CDATA // beyond Text and call that alone before super.setText(). if (text == null) { return; } append(text.getText()); }
private boolean isAllWhitespace(Object obj) { String str = null; if (obj instanceof String) { str = (String) obj; } else if (obj instanceof Text) { str = ((Text) obj).getText(); } else if (obj instanceof EntityRef) { return false; } else { return false; } for (int i = 0; i < str.length(); i++) { if (!Verifier.isXMLWhitespace(str.charAt(i))) return false; } return true; }
private static Attribute toAttribute (final org.jdom.Content c) { if (c == null) return null; if (c instanceof org.jdom.Text) return new StringAttribute(((org.jdom.Text)c).getText()); return new XmlAttribute((org.jdom.Content)c.clone()); }