Clover coverage report - dom4j - 1.6.1 Coverage timestamp: ma mei 16 2005 14:23:01 GMT+01:00 FRAMES NO FRAMES |
file stats: | LOC: | 89 |  | Methods: | 4
| NCLOC: | 28 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
AttributeHelper.java | 16,7% | 27,3% | 50% | 28,6% |

1 |  | /*
2 |  | * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3 |  | *
4 |  | * This software is open source.
5 |  | * See the bottom of this file for the licence.
6 |  | */
7 |  |
8 |  | package org.dom4j.util;
9 |  |
10 |  | import org.dom4j.Attribute;
11 |  | import org.dom4j.Element;
12 |  | import org.dom4j.QName;
13 |  |
14 |  | /**
15 |  | * <p>
16 |  | * <code>AttributeHelper</code> a number of helper methods for working with
17 |  | * attribute values.
18 |  | * </p>
19 |  | *
20 |  | * @author <a href="mailto:jstrachan@apache.org">James Strachan </a>
21 |  | * @version $Revision: 1.7 $
22 |  | */
23 |  | public class AttributeHelper {
24 | 0 | protected AttributeHelper() {
25 |  | }
26 |  |
27 | 103 | public static boolean booleanValue(Element element, String attributeName) {
28 | 103 | return booleanValue(element.attribute(attributeName));
29 |  | }
30 |  |
31 | 0 | public static boolean booleanValue(Element element, QName attributeQName) {
32 | 0 | return booleanValue(element.attribute(attributeQName));
33 |  | }
34 |  |
35 | 103 | protected static boolean booleanValue(Attribute attribute) {
36 | 103 | if (attribute == null) {
37 | 103 | return false;
38 |  | }
39 |  |
40 | 0 | Object value = attribute.getData();
41 |  |
42 | 0 | if (value == null) {
43 | 0 | return false;
44 | 0 | } else if (value instanceof Boolean) {
45 | 0 | Boolean b = (Boolean) value;
46 |  |
47 | 0 | return b.booleanValue();
48 |  | } else {
49 | 0 | return "true".equalsIgnoreCase(value.toString());
50 |  | }
51 |  | }
52 |  | }
53 |  |
54 |  | /*
55 |  | * Redistribution and use of this software and associated documentation
56 |  | * ("Software"), with or without modification, are permitted provided that the
57 |  | * following conditions are met:
58 |  | *
59 |  | * 1. Redistributions of source code must retain copyright statements and
60 |  | * notices. Redistributions must also contain a copy of this document.
61 |  | *
62 |  | * 2. Redistributions in binary form must reproduce the above copyright notice,
63 |  | * this list of conditions and the following disclaimer in the documentation
64 |  | * and/or other materials provided with the distribution.
65 |  | *
66 |  | * 3. The name "DOM4J" must not be used to endorse or promote products derived
67 |  | * from this Software without prior written permission of MetaStuff, Ltd. For
68 |  | * written permission, please contact dom4j-info@metastuff.com.
69 |  | *
70 |  | * 4. Products derived from this Software may not be called "DOM4J" nor may
71 |  | * "DOM4J" appear in their names without prior written permission of MetaStuff,
72 |  | * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
73 |  | *
74 |  | * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
75 |  | *
76 |  | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
77 |  | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
78 |  | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
79 |  | * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
80 |  | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
81 |  | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
82 |  | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
83 |  | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
84 |  | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
85 |  | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
86 |  | * POSSIBILITY OF SUCH DAMAGE.
87 |  | *
88 |  | * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
89 |  | */