Clover coverage report - dom4j - 1.6.1
Coverage timestamp: ma mei 16 2005 14:23:01 GMT+01:00
file stats: LOC: 219   Methods: 31
NCLOC: 116   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DOMAttribute.java 0% 2,8% 3,2% 2,9%
coverage coverage
 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.dom;
 9   
 10    import org.dom4j.Element;
 11    import org.dom4j.QName;
 12    import org.dom4j.tree.DefaultAttribute;
 13   
 14    import org.w3c.dom.DOMException;
 15    import org.w3c.dom.Document;
 16    import org.w3c.dom.NamedNodeMap;
 17    import org.w3c.dom.NodeList;
 18   
 19    /**
 20    * <p>
 21    * <code>DOMAttribute</code> implements a doubly linked attribute which
 22    * supports the W3C DOM API.
 23    * </p>
 24    *
 25    * @author <a href="mailto:jstrachan@apache.org">James Strachan </a>
 26    * @version $Revision: 1.14 $
 27    */
 28    public class DOMAttribute extends DefaultAttribute implements org.w3c.dom.Attr {
 29  0 public DOMAttribute(QName qname) {
 30  0 super(qname);
 31    }
 32   
 33  114 public DOMAttribute(QName qname, String value) {
 34  114 super(qname, value);
 35    }
 36   
 37  0 public DOMAttribute(Element parent, QName qname, String value) {
 38  0 super(parent, qname, value);
 39    }
 40   
 41    // org.w3c.dom.Node interface
 42    // -------------------------------------------------------------------------
 43  0 public boolean supports(String feature, String version) {
 44  0 return DOMNodeHelper.supports(this, feature, version);
 45    }
 46   
 47  0 public String getNamespaceURI() {
 48  0 return getQName().getNamespaceURI();
 49    }
 50   
 51  0 public String getPrefix() {
 52  0 return getQName().getNamespacePrefix();
 53    }
 54   
 55  0 public void setPrefix(String prefix) throws DOMException {
 56  0 DOMNodeHelper.setPrefix(this, prefix);
 57    }
 58   
 59  0 public String getLocalName() {
 60  0 return getQName().getName();
 61    }
 62   
 63  0 public String getNodeName() {
 64  0 return getName();
 65    }
 66   
 67    // already part of API
 68    //
 69    // public short getNodeType();
 70  0 public String getNodeValue() throws DOMException {
 71  0 return DOMNodeHelper.getNodeValue(this);
 72    }
 73   
 74  0 public void setNodeValue(String nodeValue) throws DOMException {
 75  0 DOMNodeHelper.setNodeValue(this, nodeValue);
 76    }
 77   
 78  0 public org.w3c.dom.Node getParentNode() {
 79    // Per http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-637646024
 80    // and the NIST conformance tests, Attr.getParentNode() should always
 81    // return null
 82  0 return null;
 83    }
 84   
 85  0 public NodeList getChildNodes() {
 86  0 return DOMNodeHelper.getChildNodes(this);
 87    }
 88   
 89  0 public org.w3c.dom.Node getFirstChild() {
 90  0 return DOMNodeHelper.getFirstChild(this);
 91    }
 92   
 93  0 public org.w3c.dom.Node getLastChild() {
 94  0 return DOMNodeHelper.getLastChild(this);
 95    }
 96   
 97  0 public org.w3c.dom.Node getPreviousSibling() {
 98  0 return DOMNodeHelper.getPreviousSibling(this);
 99    }
 100   
 101  0 public org.w3c.dom.Node getNextSibling() {
 102  0 return DOMNodeHelper.getNextSibling(this);
 103    }
 104   
 105  0 public NamedNodeMap getAttributes() {
 106  0 return null;
 107    }
 108   
 109  0 public Document getOwnerDocument() {
 110  0 return DOMNodeHelper.getOwnerDocument(this);
 111    }
 112   
 113  0 public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
 114    org.w3c.dom.Node refChild) throws DOMException {
 115  0 checkNewChildNode(newChild);
 116   
 117  0 return DOMNodeHelper.insertBefore(this, newChild, refChild);
 118    }
 119   
 120  0 public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
 121    org.w3c.dom.Node oldChild) throws DOMException {
 122  0 checkNewChildNode(newChild);
 123   
 124  0 return DOMNodeHelper.replaceChild(this, newChild, oldChild);
 125    }
 126   
 127  0 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
 128    throws DOMException {
 129  0 return DOMNodeHelper.removeChild(this, oldChild);
 130    }
 131   
 132  0 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
 133    throws DOMException {
 134  0 checkNewChildNode(newChild);
 135   
 136  0 return DOMNodeHelper.appendChild(this, newChild);
 137    }
 138   
 139  0 private void checkNewChildNode(org.w3c.dom.Node newChild)
 140    throws DOMException {
 141  0 final int nodeType = newChild.getNodeType();
 142   
 143  0 if (!((nodeType == org.w3c.dom.Node.TEXT_NODE)
 144    || (nodeType == org.w3c.dom.Node.ENTITY_REFERENCE_NODE))) {
 145  0 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
 146    "The node cannot be a child of attribute");
 147    }
 148    }
 149   
 150  0 public boolean hasChildNodes() {
 151  0 return DOMNodeHelper.hasChildNodes(this);
 152    }
 153   
 154  0 public org.w3c.dom.Node cloneNode(boolean deep) {
 155  0 return DOMNodeHelper.cloneNode(this, deep);
 156    }
 157   
 158  0 public void normalize() {
 159  0 DOMNodeHelper.normalize(this);
 160    }
 161   
 162  0 public boolean isSupported(String feature, String version) {
 163  0 return DOMNodeHelper.isSupported(this, feature, version);
 164    }
 165   
 166  0 public boolean hasAttributes() {
 167  0 return DOMNodeHelper.hasAttributes(this);
 168    }
 169   
 170    // org.w3c.dom.Attr interface
 171    // -------------------------------------------------------------------------
 172    // public String getName();
 173  0 public boolean getSpecified() {
 174  0 return true;
 175    }
 176   
 177    // public String getValue();
 178    // public void setValue(String value) throws DOMException;
 179  0 public org.w3c.dom.Element getOwnerElement() {
 180  0 return DOMNodeHelper.asDOMElement(getParent());
 181    }
 182    }
 183   
 184    /*
 185    * Redistribution and use of this software and associated documentation
 186    * ("Software"), with or without modification, are permitted provided that the
 187    * following conditions are met:
 188    *
 189    * 1. Redistributions of source code must retain copyright statements and
 190    * notices. Redistributions must also contain a copy of this document.
 191    *
 192    * 2. Redistributions in binary form must reproduce the above copyright notice,
 193    * this list of conditions and the following disclaimer in the documentation
 194    * and/or other materials provided with the distribution.
 195    *
 196    * 3. The name "DOM4J" must not be used to endorse or promote products derived
 197    * from this Software without prior written permission of MetaStuff, Ltd. For
 198    * written permission, please contact dom4j-info@metastuff.com.
 199    *
 200    * 4. Products derived from this Software may not be called "DOM4J" nor may
 201    * "DOM4J" appear in their names without prior written permission of MetaStuff,
 202    * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
 203    *
 204    * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
 205    *
 206    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
 207    * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 208    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 209    * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
 210    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 211    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 212    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 213    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 214    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 215    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 216    * POSSIBILITY OF SUCH DAMAGE.
 217    *
 218    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
 219    */