1 7 8 package org.dom4j.util; 9 10 import org.dom4j.Attribute; 11 import org.dom4j.Element; 12 import org.dom4j.QName; 13 14 23 public class AttributeHelper { 24 protected AttributeHelper() { 25 } 26 27 public static boolean booleanValue(Element element, String attributeName) { 28 return booleanValue(element.attribute(attributeName)); 29 } 30 31 public static boolean booleanValue(Element element, QName attributeQName) { 32 return booleanValue(element.attribute(attributeQName)); 33 } 34 35 protected static boolean booleanValue(Attribute attribute) { 36 if (attribute == null) { 37 return false; 38 } 39 40 Object value = attribute.getData(); 41 42 if (value == null) { 43 return false; 44 } else if (value instanceof Boolean ) { 45 Boolean b = (Boolean ) value; 46 47 return b.booleanValue(); 48 } else { 49 return "true".equalsIgnoreCase(value.toString()); 50 } 51 } 52 } 53 54 90 | Popular Tags |