Here you can find the source of getAttributeBoolean(Element aElement, String aAttributeName)
boolean
value of the specified attribute from the given Element.
Parameter | Description |
---|---|
aElement | The owning <code>Element</code>. |
aAttributeName | The name of the attribute. |
public static boolean getAttributeBoolean(Element aElement, String aAttributeName)
//package com.java2s; import org.w3c.dom.*; public class Main { /**//from ww w . ja v a 2s .c om * Returns the <code>boolean</code> value of the specified attribute from the given Element. * * @param aElement The owning <code>Element</code>. * @param aAttributeName The name of the attribute. * @return boolean if the attribute has the value of "true" then true, else false */ public static boolean getAttributeBoolean(Element aElement, String aAttributeName) { return "true".equals(getAttribute(aElement, aAttributeName)); //$NON-NLS-1$ } /** * Returns the <code>boolean</code> value of the specified attribute from the given Element. * If the attribute is empty then the default value is returned. * * @param aElement The owning <code>Element</code>. * @param aAttr The name of the attribute. * @param aDefault The default value if the attribute value is empty. * @return boolean */ public static boolean getAttributeBoolean(Element aElement, String aAttr, boolean aDefault) { String boolStr = aElement.getAttribute(aAttr); return boolStr.equals("") ? aDefault : getAttributeBoolean(aElement, aAttr); //$NON-NLS-1$ } /** * Returns the value of the specified attribute from the given Element. * * @param aElement The owning <code>Element</code>. * @param aAttributeName The name of the attribute. * @return String */ public static String getAttribute(Element aElement, String aAttributeName) { return aElement.getAttribute(aAttributeName); } /** * Retrieves the given attribute from the given Element. If the attribute had an empty String * value then the default argument is returned. * * @param aElement The owning <code>Element</code>. * @param aAttr The name of the attribute. * @param aDefault The default value if the attribute value is empty. */ public static String getAttribute(Element aElement, String aAttr, String aDefault) { String str = getAttribute(aElement, aAttr); return str.equals("") ? aDefault : str; //$NON-NLS-1$ } }