static private void mergeAdjacentText(Node parent, StringBuilder collectorBuf) { Node child = parent.getFirstChild(); while (child != null) { Node next = child.getNextSibling(); if (child instanceof Text) { boolean atFirstText = true; while (next instanceof Text) { // if (atFirstText) { collectorBuf.setLength(0); collectorBuf.ensureCapacity(child.getNodeValue().length() + next.getNodeValue().length()); collectorBuf.append(child.getNodeValue()); atFirstText = false; } collectorBuf.append(next.getNodeValue()); parent.removeChild(next); next = child.getNextSibling(); } if (!atFirstText && collectorBuf.length() != 0) { ((CharacterData) child).setData(collectorBuf.toString()); } } else { mergeAdjacentText(child, collectorBuf); } child = next; } }
((CharacterData) collectorTextChild).setData(collectorTextChildBuff.toString()); collectorTextChildBuff.setLength(0); ((CharacterData) collectorTextChild).setData(collectorTextChildBuff.toString()); collectorTextChildBuff.setLength(0); ((CharacterData) collectorTextChild).setData(collectorTextChildBuff.toString()); collectorTextChildBuff.setLength(0);
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
/** * @since SAAJ 1.2 */ public void setData(String data) throws DOMException { textRep.setData(data); }
/** * @since SAAJ 1.2 */ public void setData(String data) throws DOMException { textRep.setData(data); }
/** * @since SAAJ 1.2 */ public void setData(String data) throws DOMException { textRep.setData(data); }
/** * If this is a Text node then this method will set its value, otherwise it sets the value of * the immediate (Text) child of this node. The value of the immediate child of this node can be * set only if, there is one child node and that node is a Text node, or if there are no * children in which case a child Text node will be created. * * @param value the text to set * @throws IllegalStateException if the node is not a Text node and either has more than one * child node or has a child node that is not a Text node */ public void setValue(String value) { target.setData(value); }
@Override public void setData(String data) throws DOMException { domNode.setData(data); }
/** * If this is a Text node then this method will set its value, otherwise it sets the value of * the immediate (Text) child of this node. The value of the immediate child of this node can be * set only if, there is one child node and that node is a Text node, or if there are no * children in which case a child Text node will be created. * * @param value the text to set * @throws IllegalStateException if the node is not a Text node and either has more than one * child node or has a child node that is not a Text node */ public void setValue(String value) { target.setData(value); }
/** * The character data of the node that implements this interface. The DOM implementation may not * put arbitrary limits on the amount of data that may be stored in a <code>CharacterData</code> * node. However, implementation limits may mean that the entirety of a node's data may not fit * into a single <code>DOMString</code>. In such cases, the user may call * <code>substringData</code> to retrieve the data in appropriately sized pieces. * * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @throws DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit * in a <code>DOMString</code> variable on the implementation platform. */ public void setData(String data) throws DOMException { target.setData(data); }
/** * The character data of the node that implements this interface. The DOM implementation may not * put arbitrary limits on the amount of data that may be stored in a <code>CharacterData</code> * node. However, implementation limits may mean that the entirety of a node's data may not fit * into a single <code>DOMString</code>. In such cases, the user may call * <code>substringData</code> to retrieve the data in appropriately sized pieces. * * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @throws DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit * in a <code>DOMString</code> variable on the implementation platform. */ public void setData(String data) throws DOMException { target.setData(data); }
public void setData(String data) throws DOMException { try { _delegate.setData(data); } catch (org.w3c.dom.DOMException ex) { throw wrap(ex); } }
/** * Merges adjacent text/cdata nodes, so that there are no * adjacent text/cdata nodes. Operates recursively * on the entire subtree. You thus lose information * about any CDATA sections occurring in the doc. * * @see #simplify */ static public void mergeAdjacentText(Node node) { Node child = node.getFirstChild(); while (child != null) { if (child instanceof Text || child instanceof CDATASection) { Node next = child.getNextSibling(); if (next instanceof Text || next instanceof CDATASection) { String fullText = child.getNodeValue() + next.getNodeValue(); ((CharacterData) child).setData(fullText); node.removeChild(next); } } else { mergeAdjacentText(child); } child = child.getNextSibling(); } }
static private void mergeAdjacentText(Node parent, StringBuilder collectorBuf) { Node child = parent.getFirstChild(); while (child != null) { Node next = child.getNextSibling(); if (child instanceof Text) { boolean atFirstText = true; while (next instanceof Text) { // if (atFirstText) { collectorBuf.setLength(0); collectorBuf.ensureCapacity(child.getNodeValue().length() + next.getNodeValue().length()); collectorBuf.append(child.getNodeValue()); atFirstText = false; } collectorBuf.append(next.getNodeValue()); parent.removeChild(next); next = child.getNextSibling(); } if (!atFirstText && collectorBuf.length() != 0) { ((CharacterData) child).setData(collectorBuf.toString()); } } else { mergeAdjacentText(child, collectorBuf); } child = next; } }
public void endCDATA() { cdataSection.setData(cdata.toString()); element.appendChild(cdataSection); LocationMap extendedAttributes = getLocationMap(cdataSection); cdata = null; saveLocation(); extendedAttributes.setEndLine(line); extendedAttributes.setEndColumn(column); }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }