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