nu.xom.Text类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中nu.xom.Text类的一些代码示例,展示了Text类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text类的具体详情如下:
包路径:nu.xom.Text
类名称:Text

Text介绍

暂无

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

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();
}

代码示例来源:origin: cmu-phil/tetrad

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()));

代码示例来源:origin: nu.validator/htmlparser

@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;

代码示例来源:origin: nu.validator.htmlparser/htmlparser

@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);
  }
}

代码示例来源:origin: com.avast/syringe

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);
}

代码示例来源:origin: cmu-phil/tetrad

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();

代码示例来源:origin: sanity/tahrir

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());
    }
  }
}

代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-xom

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);
}

代码示例来源:origin: org.concordion/concordion

public Element appendText(String text) {
  xomElement.appendChild(new nu.xom.Text(text));
  return this;
}

代码示例来源:origin: com.io7m.jstructural/io7m-jstructural-xom

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);

代码示例来源:origin: org.xml-cml/cmlxom

/**
 * 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);
  }
}

代码示例来源:origin: jaxen/jaxen

public String getTextStringValue(Object o) {
  return (o instanceof Text ? ((Text)o).getValue() : null);
}

代码示例来源:origin: nu.validator/htmlparser

/**
 * <code>return new Text(string);</code>
 * @param string
 * @return
 */
public Text makeText(String string) {
  return new Text(string);
}

代码示例来源:origin: org.xml-cml/cmlxom

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;
}

代码示例来源:origin: stackoverflow.com

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)));
  }
}

代码示例来源:origin: org.concordion/concordion

public Element prependText(String text) {
  xomElement.insertChild(new nu.xom.Text(text), 0);
  return this;
}

代码示例来源:origin: stackoverflow.com

// 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);
}

代码示例来源:origin: stackoverflow.com

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();
}

代码示例来源:origin: org.xml-cml/cmlxom

/** 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);
  }
}

代码示例来源:origin: org.xml-cml/cmlxom

((Attribute)node).setValue(val);
} else if (node instanceof Text) {
  ((Text)node).setValue(val);
} else {
  throw new RuntimeException("BUG "+node.getClass());

相关文章

微信公众号

最新文章

更多