Clover coverage report - dom4j - 1.5
Coverage timestamp: vr sep 3 2004 20:47:03 GMT+01:00
file stats: LOC: 195   Methods: 19
NCLOC: 99   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractAttribute.java 60% 75% 57,9% 68,5%
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: AbstractAttribute.java,v 1.19 2004/06/25 08:03:40 maartenc Exp $
 8    */
 9   
 10    package org.dom4j.tree;
 11   
 12    import java.io.IOException;
 13    import java.io.Writer;
 14   
 15    import org.dom4j.Attribute;
 16    import org.dom4j.Element;
 17    import org.dom4j.Namespace;
 18    import org.dom4j.Node;
 19    import org.dom4j.Visitor;
 20   
 21    /** <p><code>AbstractNamespace</code> is an abstract base class for
 22    * tree implementors to use for implementation inheritence.</p>
 23    *
 24    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 25    * @version $Revision: 1.19 $
 26    */
 27    public abstract class AbstractAttribute extends AbstractNode implements Attribute {
 28   
 29  42 public short getNodeType() {
 30  42 return ATTRIBUTE_NODE;
 31    }
 32   
 33   
 34  0 public void setNamespace(Namespace namespace) {
 35  0 throw new UnsupportedOperationException("This Attribute is read only and cannot be changed" );
 36    }
 37   
 38  614 public String getText() {
 39  614 return getValue();
 40    }
 41   
 42  0 public void setText(String text) {
 43  0 setValue(text);
 44    }
 45   
 46  0 public void setValue(String value) {
 47  0 throw new UnsupportedOperationException("This Attribute is read only and cannot be changed" );
 48    }
 49   
 50  0 public Object getData() {
 51  0 return getValue();
 52    }
 53   
 54  0 public void setData(Object data) {
 55  0 setValue( data == null ? null : data.toString() );
 56    }
 57   
 58  91214 public String toString() {
 59  91214 return super.toString() + " [Attribute: name " + getQualifiedName()
 60    + " value \"" + getValue() + "\"]";
 61    }
 62   
 63  22 public String asXML() {
 64  22 return getQualifiedName() + "=\"" + getValue() + "\"";
 65    }
 66   
 67  0 public void write(Writer writer) throws IOException {
 68  0 writer.write( getQualifiedName() );
 69  0 writer.write( "=\"" );
 70  0 writer.write( getValue() );
 71  0 writer.write( "\"" );
 72    }
 73   
 74  0 public void accept(Visitor visitor) {
 75  0 visitor.visit(this);
 76    }
 77   
 78    // QName methods
 79   
 80  6236 public Namespace getNamespace() {
 81  6236 return getQName().getNamespace();
 82    }
 83   
 84  18218 public String getName() {
 85  18218 return getQName().getName();
 86    }
 87   
 88  30 public String getNamespacePrefix() {
 89  30 return getQName().getNamespacePrefix();
 90    }
 91   
 92  10306 public String getNamespaceURI() {
 93  10306 return getQName().getNamespaceURI();
 94    }
 95   
 96  107932 public String getQualifiedName() {
 97  107932 return getQName().getQualifiedName();
 98    }
 99   
 100  10 public String getPath(Element context) {
 101  10 StringBuffer result = new StringBuffer();
 102   
 103  10 Element parent = getParent();
 104  10 if ((parent != null) && (parent != context)) {
 105  10 result.append(parent.getPath(context));
 106  10 result.append("/");
 107    }
 108  10 result.append("@");
 109   
 110  10 String uri = getNamespaceURI();
 111  10 String prefix = getNamespacePrefix();
 112  10 if (uri == null || uri.length() == 0 || prefix == null || prefix.length() == 0) {
 113  8 result.append(getName());
 114    } else {
 115  2 result.append(getQualifiedName());
 116    }
 117   
 118  10 return result.toString();
 119    }
 120   
 121  10 public String getUniquePath(Element context) {
 122  10 StringBuffer result = new StringBuffer();
 123   
 124  10 Element parent = getParent();
 125  10 if ((parent != null) && (parent != context)) {
 126  10 result.append(parent.getUniquePath(context));
 127  10 result.append("/");
 128    }
 129  10 result.append("@");
 130   
 131  10 String uri = getNamespaceURI();
 132  10 String prefix = getNamespacePrefix();
 133  10 if (uri == null || uri.length() == 0 || prefix == null || prefix.length() == 0) {
 134  8 result.append(getName());
 135    } else {
 136  2 result.append(getQualifiedName());
 137    }
 138   
 139  10 return result.toString();
 140    }
 141   
 142  0 protected Node createXPathResult(Element parent) {
 143  0 return new DefaultAttribute(parent, getQName(), getValue());
 144    }
 145    }
 146   
 147   
 148   
 149   
 150   
 151   
 152    /*
 153    * Redistribution and use of this software and associated documentation
 154    * ("Software"), with or without modification, are permitted provided
 155    * that the following conditions are met:
 156    *
 157    * 1. Redistributions of source code must retain copyright
 158    * statements and notices. Redistributions must also contain a
 159    * copy of this document.
 160    *
 161    * 2. Redistributions in binary form must reproduce the
 162    * above copyright notice, this list of conditions and the
 163    * following disclaimer in the documentation and/or other
 164    * materials provided with the distribution.
 165    *
 166    * 3. The name "DOM4J" must not be used to endorse or promote
 167    * products derived from this Software without prior written
 168    * permission of MetaStuff, Ltd. For written permission,
 169    * please contact dom4j-info@metastuff.com.
 170    *
 171    * 4. Products derived from this Software may not be called "DOM4J"
 172    * nor may "DOM4J" appear in their names without prior written
 173    * permission of MetaStuff, Ltd. DOM4J is a registered
 174    * trademark of MetaStuff, Ltd.
 175    *
 176    * 5. Due credit should be given to the DOM4J Project -
 177    * http://www.dom4j.org
 178    *
 179    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
 180    * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 181    * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 182    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 183    * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 184    * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 185    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 186    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 187    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 188    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 189    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 190    * OF THE POSSIBILITY OF SUCH DAMAGE.
 191    *
 192    * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
 193    *
 194    * $Id: AbstractAttribute.java,v 1.19 2004/06/25 08:03:40 maartenc Exp $
 195    */