Package org.w3c.dom

Examples of org.w3c.dom.CharacterData


    if (parentEl == null) {
      return null;
    }
    Node          tempNode = parentEl.getFirstChild();
    StringBuffer  strBuf   = new StringBuffer();
    CharacterData charData;

    while (tempNode != null) {
      switch (tempNode.getNodeType()) {
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE : charData = (CharacterData)tempNode;
                                       strBuf.append(charData.getData());
                                       break;
      }
      tempNode = tempNode.getNextSibling();
    }
    return strBuf.toString();
View Full Code Here


    if (parentEl == null) {
      return null;
    }
    Node          tempNode = parentEl.getFirstChild();
    StringBuffer  strBuf   = new StringBuffer();
    CharacterData charData;

    while (tempNode != null) {
      switch (tempNode.getNodeType()) {
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE : charData = (CharacterData)tempNode;
                                       strBuf.append(charData.getData());
                                       break;
      }
      tempNode = tempNode.getNextSibling();
    }
    return strBuf.toString();
View Full Code Here

    if (parentEl == null) {
      return null;
    }
    Node          tempNode = parentEl.getFirstChild();
    StringBuffer  strBuf   = new StringBuffer();
    CharacterData charData;

    while (tempNode != null) {
      switch (tempNode.getNodeType()) {
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE : charData = (CharacterData)tempNode;
                                       strBuf.append(charData.getData());
                                       break;
      }
      tempNode = tempNode.getNextSibling();
    }
    return strBuf.toString();
View Full Code Here

  private boolean isEmptyText(Node node)
  {
    if (! (node instanceof CharacterData))
      return false;

    CharacterData data = (CharacterData) node;

    return data.getData().trim().length() == 0;
  }
View Full Code Here

      String data = attrNode.getNodeValue();

      return data;
    }
    else if (node instanceof CharacterData) {
      CharacterData cData = (CharacterData) node;

      return cData.getData();
    }

    if (! (node instanceof Element))
      return null;
View Full Code Here

            final Node node = nodes.item( i );
            if( node instanceof Element ) {
                final Configuration child = toConfiguration( (Element)node );
                configuration.addChild( child );
            } else if( node instanceof CharacterData ) {
                final CharacterData data = (CharacterData)node;
                content += data.getData();
                flag = true;
            }
        }

        if( flag ) {
View Full Code Here

        if (parentEl == null) {
            return null;
        }
        Node tempNode = parentEl.getFirstChild();
        StringBuffer strBuf = new StringBuffer();
        CharacterData charData;

        while (tempNode != null) {
            switch (tempNode.getNodeType()) {
                case Node.TEXT_NODE :
                case Node.CDATA_SECTION_NODE:
                    charData = (CharacterData) tempNode;
                    strBuf.append(charData.getData());
                    break;
            }
            tempNode = tempNode.getNextSibling();
        }
        return strBuf.toString();
View Full Code Here

   * @param elemValue the new element text
   */
  public void editElement(String elemValue) {
    if (input != null) {
      NodeList list = input.getChildNodes();
      CharacterData textNode = null;

      for (int i = 0; i < list.getLength(); i++) {
        if (list.item(i) instanceof IDOMText) {
          IDOMText text = (IDOMText) list.item(i);
          if (!text.isElementContentWhitespace()) {
            // This is a naive assumption that the first text space
            // is the one we want to edit. What to do?
            textNode = text;
            break;
          }
        }
      }

      // If new value is empty...
      if (elemValue == null || elemValue.trim().equals("")) { //$NON-NLS-1$
        // ...and existing value is non-empty...
        if (textNode != null && !textNode.getData().trim().equals("")) { //$NON-NLS-1$
          // ...remove the existing element.
          input.removeChild(textNode);
        }
      }
      // If new value is non-empty...
      else {
        // ...ensure we have an existing element, and...
        if (textNode == null) {
          textNode = input.getOwnerDocument().createTextNode(""); //$NON-NLS-1$
          input.appendChild(textNode);
        }
        // ...if existing value is different...
        if (!elemValue.equals(textNode.getData())) {
          // ...change the existing element.
          textNode.setData(elemValue);
        }
      }
    }
  }
View Full Code Here

    }
  }
 
  private void validateEmptyText(Object bean, Node childNode)
  {
    CharacterData cData = (CharacterData) childNode;
   
    String data = cData.getData().trim();
   
    if (data.length() > 0) {
      throw new ConfigException(L.l("Unexpected text in {0} at\n  '{1}'",
                                    bean.getClass().getName(),
                                    data));
View Full Code Here

  private boolean isEmptyText(Node node)
  {
    if (! (node instanceof CharacterData))
      return false;

    CharacterData data = (CharacterData) node;

    return data.getData().trim().length() == 0;
  }
View Full Code Here

TOP

Related Classes of org.w3c.dom.CharacterData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.