Java XML Has Child hasActivityChildNode(Node node)

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

Description

Checks whether the node has a child node that represents a BPEL activity.

License

Open Source License

Parameter

Parameter Description
node a parameter

Return

whether there is an activity child node

Declaration

public static boolean hasActivityChildNode(Node node) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

import java.util.HashSet;

import org.w3c.dom.Node;
import org.w3c.dom.Text;

public class Main {
    public static final Collection<String> BPEL_ACTIVITIES = new HashSet<String>() {
        private static final long serialVersionUID = -1626491688586809929L;
        {/*from   w w w  .j  a v a 2s  .  c  o  m*/
            add("invoke");
            add("receive");
            add("reply");
            add("wait");
            add("exit");
            add("empty");
            add("throw");
            add("rethrow");
            add("validate");
            add("assign");
            add("compensate");
            add("compensatescope");
            add("pick");
            add("onmessage");
            add("onalarm");
            add("sequence");
            add("while");
            add("repeatuntil");
            add("foreach");
            add("flow");
            add("scope");
        }
    };

    /**
     * Checks whether the node has a child node that represents a 
     * BPEL activity.
     * 
     * @param node
     * @return whether there is an activity child node
     */
    public static boolean hasActivityChildNode(Node node) {
        boolean foundNonTextChild = false;

        for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            if (!(child instanceof Text)) {
                if (BPEL_ACTIVITIES.contains(child.getNodeName())) {
                    foundNonTextChild = true;
                }
            }
        }

        return foundNonTextChild;
    }
}

Related

  1. getChildHash(Element elem, String elementName, String attrName)
  2. getLastVisibleChildElement(Node parent, Hashtable hiddenNodes)
  3. hasAnyChildElement(final Element e)
  4. hasChild(Element element, String child)
  5. hasChild(Element node, String name)
  6. hasChild(Element parent, String nodeName)