Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/

import org.w3c.dom.Node;

public class Main {
    /**
     * returns the Node Type As String
     * @param node
     * @param cftype 
     * @return
     */
    public static String getTypeAsString(Node node, boolean cftype) {
        String suffix = cftype ? "" : "_NODE";

        switch (node.getNodeType()) {
        case Node.ATTRIBUTE_NODE:
            return "ATTRIBUTE" + suffix;
        case Node.CDATA_SECTION_NODE:
            return "CDATA_SECTION" + suffix;
        case Node.COMMENT_NODE:
            return "COMMENT" + suffix;
        case Node.DOCUMENT_FRAGMENT_NODE:
            return "DOCUMENT_FRAGMENT" + suffix;
        case Node.DOCUMENT_NODE:
            return "DOCUMENT" + suffix;
        case Node.DOCUMENT_TYPE_NODE:
            return "DOCUMENT_TYPE" + suffix;
        case Node.ELEMENT_NODE:
            return "ELEMENT" + suffix;
        case Node.ENTITY_NODE:
            return "ENTITY" + suffix;
        case Node.ENTITY_REFERENCE_NODE:
            return "ENTITY_REFERENCE" + suffix;
        case Node.NOTATION_NODE:
            return "NOTATION" + suffix;
        case Node.PROCESSING_INSTRUCTION_NODE:
            return "PROCESSING_INSTRUCTION" + suffix;
        case Node.TEXT_NODE:
            return "TEXT" + suffix;
        default:
            return "UNKNOW" + suffix;
        }
    }
}