Refine search
public String getValue() { // currentElement.getValue() not used as this includes text of child elements, which we don't want. StringBuffer result = new StringBuffer(); int childCount = currentElement.getChildCount(); for(int i = 0; i < childCount; i++) { Node child = currentElement.getChild(i); if (child instanceof Text) { Text text = (Text) child; result.append(text.getValue()); } } return result.toString(); }
private static Element getCptsElement(BayesIm bayesIm) { Element cpts = new Element("cpts"); cpts.addAttribute(new Attribute("rowSumTolerance", "0.0001")); Element cpt = new Element("cpt"); cpts.appendChild(cpt); row.appendChild(new Text(s.trim()));
@Override protected void insertFosterParentedCharacters(String text, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); if (parent != null) { // always an element if not null Element parentAsElt = (Element) parent; Node prevSibling; if (tableIndex != 0 && ((prevSibling = parentAsElt.getChild(tableIndex - 1)) instanceof Text)) { Text prevAsText = (Text) prevSibling; prevAsText.setValue(prevAsText.getValue() + text); return; parentAsElt.insertChild(nodeFactory.makeText(text), tableIndex); cachedTableIndex++; return; && ((lastChild = stackParent.getChild(childCount - 1)) instanceof Text)) { Text lastAsText = (Text) lastChild; lastAsText.setValue(lastAsText.getValue() + text); return;
@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); } }
private void appendTypeInfoAnnotation(Element complexTypeEl, String typeInfo) { Element annotEl = new Element("xs:annotation", NS_SCHEMA); complexTypeEl.appendChild(annotEl); Element appInfoEl = new Element("xs:appinfo", NS_SCHEMA); annotEl.appendChild(appInfoEl); Text appInfoContent = new Text("type_info"); appInfoEl.appendChild(appInfoContent); Element docEl = new Element("xs:documentation", NS_SCHEMA); annotEl.appendChild(docEl); Text docElContent = new Text(typeInfo); docEl.appendChild(docElContent); }
private static BayesIm makeBayesIm(BayesPm bayesPm, Element element2) { if (!"cpts".equals(element2.getQualifiedName())) { throw new IllegalArgumentException("Expecting 'cpts' element."); Elements elements2 = element2.getChildElements(); if (!"cpt".equals(e1.getQualifiedName())) { throw new IllegalArgumentException("Expecting 'cpt' element."); Text rowNode = (Text) e2.getChild(0); String rowString = rowNode.getValue();
private void writeNode(Node node, StringBuilder stringBuilder) { if (node instanceof ParentNode) { ParentNode parentNode = (ParentNode) node; Element mentionElement = new Element((Element)node); if(mentionElement.getLocalName().equals(TrConstants.FormatInfo.MENTION)){ stringBuilder.append('@'); } for (int childIndex = 0; childIndex < parentNode.getChildCount(); childIndex++) { writeNode(parentNode.getChild(childIndex), stringBuilder); } } else if (node instanceof Text) { Text text = (Text) node; stringBuilder.append(text.getValue()); } } }
private static SNonEmptyList<SLinkContent> linkContent( final Element ec) throws URISyntaxException { final List<SLinkContent> elements = new ArrayList<SLinkContent>(); for (int index = 0; index < ec.getChildCount(); ++index) { final Node child = ec.getChild(index); if (child instanceof Text) { final Text et = (Text) child; elements.add(SText.text(et.getValue())); continue; } else if (child instanceof Element) { final Element ecc = (Element) child; if ("image".equals(ecc.getLocalName())) { elements.add(SDocumentParser.image(ecc)); continue; } throw new UnreachableCodeException(); } else { throw new UnreachableCodeException(); } } return SNonEmptyList.newList(elements); }
public Element appendText(String text) { xomElement.appendChild(new nu.xom.Text(text)); return this; }
return SText.text(et.getValue()); if ("image".equals(ecc.getLocalName())) { return SDocumentParser.image(ecc); if ("link".equals(ecc.getLocalName())) { return SDocumentParser.link(ecc); if ("link-external".equals(ecc.getLocalName())) { return SDocumentParser.linkExternal(ecc);
/** * 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 String getTextStringValue(Object o) { return (o instanceof Text ? ((Text)o).getValue() : null); }
/** * <code>return new Text(string);</code> * @param string * @return */ public Text makeText(String string) { return new Text(string); }
public Element prependText(String text) { xomElement.insertChild(new nu.xom.Text(text), 0); return this; }
// Break the text into multiple lines and draw each one according to its own bounding box. List<? extends Text> textComponents = mText.getComponents(); for(Text currentText : textComponents) { float left = translateX(currentText.getBoundingBox().left); float bottom = translateY(currentText.getBoundingBox().bottom); canvas.drawText(currentText.getValue(), left, bottom, sTextPaint); }
public String getTitleText(final Element title) { final StringBuilder sb = new StringBuilder(); for (final Text txt : title.getDescendants(Filters.text())) { final Element parent = txt.getParentElement(); if (parent == title || parent.getAttributeValue("active", "not").equals("true")) { sb.append(txt.getValue()); } } return sb.toString(); }
/** 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); } }
((Attribute)node).setValue(val); } else if (node instanceof Text) { ((Text)node).setValue(val); } else { throw new RuntimeException("BUG "+node.getClass());