Here you can find the source of getAttributeAsBoolean(Element element, String attrName, boolean defValue)
Parameter | Description |
---|---|
element | Element |
attrName | name of the attribute to parse |
defValue | Default Boolean value if a valid Boolean text not found. |
public static final boolean getAttributeAsBoolean(Element element, String attrName, boolean defValue)
//package com.java2s; import org.w3c.dom.Element; public class Main { /**/*from w ww . j a va2s . com*/ * Get the value of the given attribute of this Element as a boolean value. * * @param element * Element * @param attrName * name of the attribute to parse * @param defValue * Default Boolean value if a valid Boolean text not found. * * @return Returns true if an attribute is found, whose value is 'true' Returns false if an attribute is found, * whose value is 'false' Returns defValue otherwise. */ public static final boolean getAttributeAsBoolean(Element element, String attrName, boolean defValue) { String value = element.getAttribute(attrName); try { if ((value != null) && (value.length() > 0)) { return Boolean.valueOf(value).booleanValue(); } } catch (Exception ex) { } return defValue; } }