Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static boolean getBoolAttribute(Node node, String name) {
        return Boolean.parseBoolean(getAttribute(node, name));
    }

    public static boolean getBoolAttribute(Node node, String name, boolean defVal) {
        String att = getAttribute(node, name);
        if (att == null)
            return defVal;
        return Boolean.parseBoolean(att);
    }

    /**
     * Returns an attribute of the specified tag with the name provided.
     *
     * @param node
     * @param name
     * @return The attribute if its defined, or null.
     */
    public static String getAttribute(Node node, String name, String defVal) {
        Node att = node.getAttributes().getNamedItem(name);
        return att == null ? defVal : att.getNodeValue();
    }

    public static String getAttribute(Node node, String name) {
        return getAttribute(node, name, null);
    }
}