Exemplo n.º 1
0
 /**
  * Sets the text value of this element. This will replace an existing Text child with the
  * provided string, or create a new one if one doesn't exist. If there is already a child in
  * this element that is not a Text node, this will throw an exception.
  *
  * @param text the new text value for this node
  * @return this element
  */
 public ERXML.E setText(String text) {
   if (_children != null) {
     if (_children.size() == 1) {
       ERXML.Node node = _children.get(0);
       if (node instanceof ERXML.Text) {
         ((ERXML.Text) node).setText(text);
       } else {
         throw new IllegalStateException(
             "There was already a non-text child of this element: " + node);
       }
     } else {
       throw new IllegalStateException("There was more than one child of this element: " + this);
     }
   } else {
     text(text);
   }
   return this;
 }
Exemplo n.º 2
0
 /**
  * Returns the text value of this element, or null if there isn't one. If there is a non-text
  * child of this element, this will throw an exception.
  *
  * @return the text value of this element
  */
 public String text() {
   ERXML.Text textNode = textNode();
   String text = (textNode != null) ? textNode.text() : null;
   return text;
 }