Java XML Attribute Get getAttributeAsBoolean(Element elem, String attribName)

Here you can find the source of getAttributeAsBoolean(Element elem, String attribName)

Description

Returns attribute as boolean for class

License

Open Source License

Parameter

Parameter Description
elem a parameter
attribName a parameter

Declaration

public static boolean getAttributeAsBoolean(Element elem, String attribName) 

Method Source Code

//package com.java2s;
/**//from   w  w w  .j  a  v  a2s. c o m
 * Copyright (c) 1999-2007, Fiorano Software Technologies Pvt. Ltd. and affiliates.
 * Copyright (c) 2008-2015, Fiorano Software Pte. Ltd. and affiliates.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Fiorano Software ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * enclosed with this product or entered into with Fiorano.
 */

import org.w3c.dom.Element;

public class Main {
    /**
     * Returns attribute as boolean for class
     *
     * @param elem
     * @param attribName
     * @return
     */
    public static boolean getAttributeAsBoolean(Element elem, String attribName) {
        String atribVal = elem.getAttribute(attribName);
        boolean retVal = false;

        try {
            retVal = Boolean.valueOf(atribVal).booleanValue();
        } catch (Exception e) {
        }
        return retVal;
    }

    /**
     * Returns attribute as boolean for class
     *
     * @param elem
     * @param attribName
     * @param defaultVal
     * @return
     */
    public static boolean getAttributeAsBoolean(Element elem, String attribName, boolean defaultVal) {
        String atribVal = elem.getAttribute(attribName);
        boolean retVal = defaultVal;

        try {
            retVal = Boolean.valueOf(atribVal).booleanValue();
        } catch (Exception e) {
        }
        return retVal;
    }
}

Related

  1. getAttribute(String key, NamedNodeMap map)
  2. getAttribute(String name, Element el)
  3. getAttribute(String name, Element element)
  4. getAttribute(String name, Element firstElement, Element secondElement)
  5. getAttribute(String name, Node node)
  6. getAttributeAsBoolean(Element element, String attrName, boolean defValue)
  7. getAttributeAsBoolean(Element element, String attrName, boolean defValue)
  8. getAttributeAsBoolean(Element element, String name)
  9. getAttributeAsBoolean(NamedNodeMap map, String name)