for (Object text : paragraph) { //paragraph may Contains 100000 of record. Text textElement = (Text) text; System.out.println(textElement.getValue()); if (this.g_hMapValues.contains(textElement.getValue())) { textElement.setValue(String.valueOf(this.g_hMapValues.get(keys))); } }
String textToReplace = text.getValue(); if (mappings.keySet().contains(textToReplace)) { text.setValue(mappings.get(textToReplace));
/** * sets text content of element. Does not support mixed content. * * @param element * @param s * @throws RuntimeException * if element already has element content */ public static void setXMLContent(Element element, String s) { List<Node> elements = CMLUtil.getQueryNodes(element, S_STAR); if (elements.size() > 0) { throw new RuntimeException( "Cannot set text with element children"); } Text text = CMLUtil.getFirstTextDescendant(element); if (text == null) { text = new Text(s); element.appendChild(text); } else { text.setValue(s); } }
public static Element normalizeWhitespaceInTextNodes(Element element) { Nodes texts = element.query(".//text()"); for (int i = 0; i < texts.size(); i++) { Text text = (Text) texts.get(i); text.setValue(normalizeSpace(text.getValue())); } return element; }
/** * some formatted XML introduces spurious WS after text strings * @param element */ public static void stripTrailingWhitespaceinTexts(Element element) { Nodes texts = element.query("//text()"); for (int i = 0; i < texts.size(); i++) { Text text = (Text) texts.get(i); String value = text.getValue(); value = Util.rightTrim(value); text.setValue(value); } }
((Attribute)node).setValue(val); } else if (node instanceof Text) { ((Text)node).setValue(val); } else { throw new RuntimeException("BUG "+node.getClass());
@Override protected void appendCharacters(Element parent, String text) throws SAXException { try { int childCount = parent.getChildCount(); Node lastChild; if (childCount != 0 && ((lastChild = parent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return; } parent.appendChild(nodeFactory.makeText(text)); } catch (XMLException e) { fatal(e); } }
@Override protected void appendCharacters(Element parent, String text) throws SAXException { try { int childCount = parent.getChildCount(); Node lastChild; if (childCount != 0 && ((lastChild = parent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return; } parent.appendChild(nodeFactory.makeText(text)); } catch (XMLException e) { fatal(e); } }
@Override protected void appendCharacters(Element parent, String text) throws SAXException { try { int childCount = parent.getChildCount(); Node lastChild; if (childCount != 0 && ((lastChild = parent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return; } parent.appendChild(nodeFactory.makeText(text)); } catch (XMLException e) { fatal(e); } }
/** sets value of a label child indicating how to join molecule. * only used in fragment builder * @param element * @param side * @param value */ public static void setLabel(CMLElement element, Position side, String value) { CMLLabel label = getLabel(element, side); if (label == null) { label = new CMLLabel(); element.appendChild(label); Text text = new Text(value); label.appendChild(text); label.setDictRef(C_E+side); } else { Text text = CMLUtil.getFirstTextDescendant(label); text.setValue(value); } }
&& ((prevSibling = parentAsElt.getChild(tableIndex - 1)) instanceof Text)) { Text prevAsText = (Text) prevSibling; prevAsText.setValue(prevAsText.getValue() + text); return; && ((lastChild = stackParent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return;
&& ((prevSibling = parentAsElt.getChild(tableIndex - 1)) instanceof Text)) { Text prevAsText = (Text) prevSibling; prevAsText.setValue(prevAsText.getValue() + text); return; && ((lastChild = stackParent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return;
&& ((prevSibling = parentAsElt.getChild(tableIndex - 1)) instanceof Text)) { Text prevAsText = (Text) prevSibling; prevAsText.setValue(prevAsText.getValue() + text); return; && ((lastChild = stackParent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return;
node.removeChild(i); } else if (!norm.equals(value)) { ((Text) child).setValue(norm);
node.removeChild(i); } else if (!norm.equals(value)) { ((Text) child).setValue(norm);