Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * This program 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.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2011 GrossCommerce
 */

import org.w3c.dom.Element;

public class Main {
    public static boolean selectBooleanAttribute(Element parent, String attrName) {
        String result = selectStringAttribute(parent, attrName, "0");

        if (result.equalsIgnoreCase("1") || result.equalsIgnoreCase("true")) {
            return true;
        }

        return false;
    }

    public static String selectStringAttribute(Element parent, String attrName, String defaultVal) {
        String result = parent.getAttribute(attrName);

        if (result == null || result.isEmpty()) {
            //            Logger.getLogger(XmlUtil.class.getName()).log(Level.INFO,
            //                    "Attribute {0} is not found", attrName);
            return defaultVal;
        }

        return result;
    }
}