Java XML Node Value Check isSimpleValueProperty(Node node)

Here you can find the source of isSimpleValueProperty(Node node)

Description

is Simple Value Property

License

Open Source License

Declaration

public static boolean isSimpleValueProperty(Node node) 

Method Source Code

//package com.java2s;
/*//from  w ww  .  j a v  a2 s  .  c o  m
 * This file is part of Dorado 7.x (http://dorado7.bsdn.org).
 * 
 * Copyright (c) 2002-2012 BSTEK Corp. All rights reserved.
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * and BSDN commercial (http://www.bsdn.org/licenses) licenses.
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at http://www.bstek.com/contact.
 */

import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;

public class Main {

    public static boolean isSimpleValueProperty(Node node) {
        if (node instanceof Attr) {
            return true;
        } else {
            Element element = (Element) node;
            NodeList childNodes = element.getChildNodes();
            int len = (childNodes != null) ? childNodes.getLength() : 0;
            if (len == 0)
                return true;
            else if (len == 1) {
                return (childNodes.item(0) instanceof Text);
            } else {
                return false;
            }
        }
    }
}

Related

  1. isNodeTheSame(Node node1, Node node2)
  2. isNodeTypeElement(Node node)
  3. isNullOrEmpty(Node node)
  4. isOrphanNode(Node node)
  5. isReturnTag(Node node)
  6. isSubTagExist(Node node, String tagName)
  7. isSuppressJoinFailure(Node node)
  8. isSynchronousInvoke(Node invoke)
  9. isText(final Node n)