Here you can find the source of getBooleanAttribute(Element element, String name, boolean defaultValue)
Parameter | Description |
---|---|
element | the element in which to find the attribute |
name | the name of the attribute |
defaultValue | the value to return if the attribute value is not parseable as a boolean |
public static boolean getBooleanAttribute(Element element, String name, boolean defaultValue)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2011 The University of Memphis. All rights reserved. * This program and the accompanying materials are made available * under the terms of the LIDA Software Framework Non-Commercial License v1.0 * which accompanies this distribution, and is available at * http://ccrg.cs.memphis.edu/assets/papers/2010/LIDA-framework-non-commercial-v1.0.pdf *******************************************************************************/ import org.w3c.dom.Element; public class Main { /**//w ww.j a v a 2 s . c o m * Get the value of an attribute of the given element with the given name as * a boolean, or return the given default value if the attribute is missing * or not parseable as a boolean. The {@link Boolean#parseBoolean} method is * used to parse the value. * * @param element * the element in which to find the attribute * @param name * the name of the attribute * @param defaultValue * the value to return if the attribute value is not parseable as * a boolean * @return the boolean value of the attribute, or the default value */ public static boolean getBooleanAttribute(Element element, String name, boolean defaultValue) { String s = element.getAttribute(name); if (s != null) return Boolean.parseBoolean(s); return defaultValue; } }