Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Copyright Universite Joseph Fourier (www.ujf-grenoble.fr)
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.w3c.dom.Node;

public class Main {
    /**
     * Convert a node type to a string. For debug purpose only.
     * 
     * @param nodeType
     *            the node type
     * @return the string
     * @throws Exception
     *             the exception
     */
    public static String nodeTypeToString(short nodeType) throws Exception {
        if (nodeType == Node.ELEMENT_NODE)
            return "ELEMENT_NODE";
        if (nodeType == Node.ATTRIBUTE_NODE)
            return "ATTRIBUTE_NODE";
        if (nodeType == Node.TEXT_NODE)
            return "TEXT_NODE";
        if (nodeType == Node.CDATA_SECTION_NODE)
            return "CDATA_SECTION_NODE";
        if (nodeType == Node.ENTITY_REFERENCE_NODE)
            return "ENTITY_REFERENCE_NODE";
        if (nodeType == Node.ENTITY_NODE)
            return "ENTITY_NODE";
        if (nodeType == Node.PROCESSING_INSTRUCTION_NODE)
            return "PROCESSING_INSTRUCTION_NODE";
        if (nodeType == Node.COMMENT_NODE)
            return "COMMENT_NODE";
        if (nodeType == Node.DOCUMENT_NODE)
            return "DOCUMENT_NODE";
        if (nodeType == Node.DOCUMENT_TYPE_NODE)
            return "DOCUMENT_TYPE_NODE";
        if (nodeType == Node.DOCUMENT_FRAGMENT_NODE)
            return "DOCUMENT_FRAGMENT_NODE";
        if (nodeType == Node.NOTATION_NODE)
            return "NOTATION_NODE";
        if (nodeType == Node.DOCUMENT_POSITION_DISCONNECTED)
            return "DOCUMENT_POSITION_DISCONNECTED";
        if (nodeType == Node.DOCUMENT_POSITION_PRECEDING)
            return "DOCUMENT_POSITION_PRECEDING";
        if (nodeType == Node.DOCUMENT_POSITION_FOLLOWING)
            return "DOCUMENT_POSITION_FOLLOWING";
        if (nodeType == Node.DOCUMENT_POSITION_CONTAINS)
            return "DOCUMENT_POSITION_CONTAINS";
        if (nodeType == Node.DOCUMENT_POSITION_CONTAINED_BY)
            return "DOCUMENT_POSITION_CONTAINED_BY";
        if (nodeType == Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)
            return "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC";

        throw new Exception("Unknown value : " + nodeType);
    }
}