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