Java XML Node Type mapNodeType(short nodeType)

Here you can find the source of mapNodeType(short nodeType)

Description

Maps a node type, as returned by to a name.

License

LGPL

Parameter

Parameter Description
nodeType a numeric Node type, one of the node type constants defined in <code>Node</code>

Return

a string name for the type

Declaration

static public String mapNodeType(short nodeType) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /** Maps node type codes to names.  Used by {@link #mapNodeType} */
    static private String[] nodeTypeMap;

    /**//from www  .  j  a  va  2  s  . c  o m
     * Maps a node type, as returned by to a name.
     * The node types returned by {@link Node#getNodeType()} are
     * numeric and are therefore inconveniently opaque.
     *
     * @param nodeType a numeric Node type, one of the node type
     * constants defined in <code>Node</code>
     * @return a string name for the type
     */
    static public String mapNodeType(short nodeType) {
        // Mostly for debugging -- the numeric node types are pretty
        // useless in any sort of log message.  Yes, this _is_
        // more elaborate than you'd guess it'd have to be, and no,
        // there's no other way to debug node types other than by grubbing
        // through org.w3c.dom.Node.java
        assert nodeType < nodeTypeMap.length;
        String val = nodeTypeMap[nodeType];
        if (val == null)
            val = "UNKNOWN!!!";
        assert val instanceof String;
        return (String) val;
    }
}

Related

  1. getSubnodesOfType(Node in, int type)
  2. getTypeAsString(Node node, boolean cftype)
  3. getTypeName(Node nameNode)
  4. getTypeName(short nodeType)
  5. hasParentNodeType(Node n, String tagToMatch)