Clover coverage report - dom4j - 1.5
Coverage timestamp: vr sep 3 2004 20:47:03 GMT+01:00
file stats: LOC: 127   Methods: 7
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultNamespace.java 50% 80% 85,7% 75%
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: DefaultNamespace.java,v 1.13 2004/06/25 08:03:41 maartenc Exp $
 8    */
 9   
 10    package org.dom4j.tree;
 11   
 12    import org.dom4j.Element;
 13    import org.dom4j.Namespace;
 14   
 15    /** <p><code>DefaultNamespace</code> implements a doubly linked node which
 16    * supports the parent relationship and is mutable.
 17    * It is useful when returning results from XPath expressions.</p>
 18    *
 19    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 20    * @version $Revision: 1.13 $
 21    */
 22    public class DefaultNamespace extends Namespace {
 23   
 24    /** The parent of this node */
 25    private Element parent;
 26   
 27    /** @param prefix is the prefix for this namespace
 28    * @param uri is the URI for this namespace
 29    */
 30  234 public DefaultNamespace(String prefix,String uri) {
 31  234 super( prefix, uri );
 32    }
 33   
 34    /** @param parent is the parent element
 35    * @param prefix is the prefix for this namespace
 36    * @param uri is the URI for this namespace
 37    */
 38  152 public DefaultNamespace(Element parent,String prefix,String uri) {
 39  152 super( prefix, uri );
 40  152 this.parent = parent;
 41    }
 42   
 43    /** @return the hash code based on the qualified name and the URI of the
 44    * namespace and the hashCode() of the parent element.
 45    */
 46  210 protected int createHashCode() {
 47  210 int hashCode = super.createHashCode();
 48  210 if ( parent != null ) {
 49  0 hashCode ^= parent.hashCode();
 50    }
 51  210 return hashCode;
 52    }
 53   
 54    /** Implements an identity based comparsion using the parent element as well as
 55    * the prefix and URI
 56    */
 57  19428 public boolean equals(Object object) {
 58  19428 if ( object instanceof DefaultNamespace ) {
 59  19428 DefaultNamespace that = (DefaultNamespace) object;
 60  19428 if ( that.parent == parent ) {
 61  19428 return super.equals( object );
 62    }
 63    }
 64  0 return false;
 65    }
 66   
 67   
 68  24 public Element getParent() {
 69  24 return parent;
 70    }
 71   
 72  24 public void setParent(Element parent) {
 73  24 this.parent = parent;
 74    }
 75   
 76  0 public boolean supportsParent() {
 77  0 return true;
 78    }
 79    }
 80   
 81   
 82   
 83   
 84    /*
 85    * Redistribution and use of this software and associated documentation
 86    * ("Software"), with or without modification, are permitted provided
 87    * that the following conditions are met:
 88    *
 89    * 1. Redistributions of source code must retain copyright
 90    * statements and notices. Redistributions must also contain a
 91    * copy of this document.
 92    *
 93    * 2. Redistributions in binary form must reproduce the
 94    * above copyright notice, this list of conditions and the
 95    * following disclaimer in the documentation and/or other
 96    * materials provided with the distribution.
 97    *
 98    * 3. The name "DOM4J" must not be used to endorse or promote
 99    * products derived from this Software without prior written
 100    * permission of MetaStuff, Ltd. For written permission,
 101    * please contact dom4j-info@metastuff.com.
 102    *
 103    * 4. Products derived from this Software may not be called "DOM4J"
 104    * nor may "DOM4J" appear in their names without prior written
 105    * permission of MetaStuff, Ltd. DOM4J is a registered
 106    * trademark of MetaStuff, Ltd.
 107    *
 108    * 5. Due credit should be given to the DOM4J Project -
 109    * http://www.dom4j.org
 110    *
 111    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
 112    * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 113    * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 114    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 115    * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 116    * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 117    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 118    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 119    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 120    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 121    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 122    * OF THE POSSIBILITY OF SUCH DAMAGE.
 123    *
 124    * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
 125    *
 126    * $Id: DefaultNamespace.java,v 1.13 2004/06/25 08:03:41 maartenc Exp $
 127    */