Java XML NodeList getMethodNames(NodeList methodNodes)

Here you can find the source of getMethodNames(NodeList methodNodes)

Description

get Method Names

License

Open Source License

Declaration

private static LinkedHashSet<String> getMethodNames(NodeList methodNodes) 

Method Source Code

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

import java.util.LinkedHashSet;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static LinkedHashSet<String> getMethodNames(NodeList methodNodes) {
        LinkedHashSet<String> methodsNames = new LinkedHashSet<String>();

        for (int i = 0; i < methodNodes.getLength(); i++) {
            Node methodNode = methodNodes.item(i);
            String methodName = getMethodName(methodNode);
            if (methodName != null) {
                methodsNames.add(methodName);
            }/*from   w  w  w  . j  a v  a  2s. c o  m*/
        }
        return methodsNames;
    }

    private static String getMethodName(Node nameNode) {

        Node firstChild = nameNode.getFirstChild();
        if (firstChild == null) {
            return null;
        }

        String nodeValue = firstChild.getNodeValue();
        String nameMethod = "";
        if (nodeValue != null && !nodeValue.trim().isEmpty()) {
            nameMethod = nodeValue;
        } else if (nameNode.getChildNodes().getLength() > 1) {
            NodeList childNodes2 = nameNode.getChildNodes();
            for (int j = 0; j < childNodes2.getLength(); j++) {
                Node child = childNodes2.item(j);
                if (!"name".equalsIgnoreCase(child.getNodeName())) {
                    continue;
                }

                nameMethod += child.getFirstChild().getNodeValue() + ".";
            }
        }
        return nameMethod;
    }
}

Related

  1. getFirstNode(NodeList nodeList)
  2. getFirstNodeValue(NodeList nodeList)
  3. getFirstTextValueFromNodeList(NodeList nList)
  4. getFirstValue(NodeList nodes)
  5. getMetaScriptType(List metaNodeList)
  6. getNode(NodeList nodes, String tagName)
  7. getNode(String tagName, NodeList nodes)
  8. getNodeByNodeName(NodeList nodes, String nodeName)
  9. getNodeFromNodeList(NodeList list, String name)