Clover coverage report - dom4j - 1.5
Coverage timestamp: vr sep 3 2004 20:47:03 GMT+01:00
file stats: LOC: 211   Methods: 18
NCLOC: 107   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DOMDocumentFactory.java 30% 42,9% 44,4% 41,3%
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: DOMDocumentFactory.java,v 1.17 2004/06/25 08:03:35 maartenc Exp $
 8    */
 9   
 10    package org.dom4j.dom;
 11   
 12    import java.util.Map;
 13   
 14    import org.dom4j.Attribute;
 15    import org.dom4j.CDATA;
 16    import org.dom4j.Comment;
 17    import org.dom4j.Document;
 18    import org.dom4j.DocumentFactory;
 19    import org.dom4j.DocumentType;
 20    import org.dom4j.Element;
 21    import org.dom4j.Entity;
 22    import org.dom4j.Namespace;
 23    import org.dom4j.ProcessingInstruction;
 24    import org.dom4j.QName;
 25    import org.dom4j.Text;
 26   
 27    /** <p><code>DOMDocumentFactory</code> is a factory of DOM4J objects
 28    * which implement the W3C DOM API.</p>
 29    *
 30    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 31    * @version $Revision: 1.17 $
 32    */
 33    public class DOMDocumentFactory extends DocumentFactory implements org.w3c.dom.DOMImplementation {
 34   
 35    /** The Singleton instance */
 36    //protected static transient DOMDocumentFactory singleton = new DOMDocumentFactory();
 37    private final static ThreadLocal singlePerThread=new ThreadLocal();
 38    private static String domDocumentFactoryClassName=null;
 39   
 40   
 41   
 42    /** <p>Access to the singleton instance of this factory.</p>
 43    *
 44    * @return the default singleon instance
 45    */
 46  14 public static DocumentFactory getInstance() {
 47  14 DOMDocumentFactory fact =(DOMDocumentFactory)singlePerThread.get();
 48  14 if (fact==null) {
 49  4 fact= new DOMDocumentFactory();
 50  4 singlePerThread.set(fact);
 51    }
 52  14 if (fact==null){
 53    }
 54  14 return fact;
 55    }
 56   
 57   
 58    // Factory methods
 59   
 60  6 public Document createDocument() {
 61  6 DOMDocument answer = new DOMDocument();
 62  6 answer.setDocumentFactory( this );
 63  6 return answer;
 64    }
 65   
 66  0 public DocumentType createDocType(String name, String publicId, String systemId) {
 67  0 return new DOMDocumentType( name, publicId, systemId );
 68    }
 69   
 70  232 public Element createElement(QName qname) {
 71  232 return new DOMElement(qname);
 72    }
 73   
 74  0 public Element createElement(QName qname, int attributeCount) {
 75  0 return new DOMElement(qname, attributeCount);
 76    }
 77   
 78  176 public Attribute createAttribute(Element owner, QName qname, String value) {
 79  176 return new DOMAttribute(qname, value);
 80    }
 81   
 82  0 public CDATA createCDATA(String text) {
 83  0 return new DOMCDATA(text);
 84    }
 85   
 86  18 public Comment createComment(String text) {
 87  18 return new DOMComment(text);
 88    }
 89   
 90  424 public Text createText(String text) {
 91  424 return new DOMText(text);
 92    }
 93   
 94  0 public Entity createEntity(String name) {
 95  0 return new DOMEntityReference(name);
 96    }
 97   
 98  0 public Entity createEntity(String name, String text) {
 99  0 return new DOMEntityReference(name, text);
 100    }
 101   
 102  234 public Namespace createNamespace(String prefix, String uri) {
 103  234 return new DOMNamespace(prefix, uri);
 104    }
 105   
 106   
 107  18 public ProcessingInstruction createProcessingInstruction(String target, String data) {
 108  18 return new DOMProcessingInstruction(target, data);
 109    }
 110   
 111  0 public ProcessingInstruction createProcessingInstruction(String target, Map data) {
 112  0 return new DOMProcessingInstruction(target, data);
 113    }
 114   
 115    // org.w3c.dom.DOMImplementation interface
 116   
 117  0 public boolean hasFeature(String feature, String version) {
 118  0 if ("XML".equalsIgnoreCase(feature) || "Core".equalsIgnoreCase(feature)) {
 119  0 return (version == null || version.length() == 0 || "1.0".equals(version) || "2.0".equals(version));
 120    }
 121  0 return false;
 122    }
 123   
 124  0 public org.w3c.dom.DocumentType createDocumentType(
 125    String qualifiedName, String publicId, String systemId
 126    ) throws org.w3c.dom.DOMException {
 127  0 return new DOMDocumentType( qualifiedName, publicId, systemId );
 128    }
 129   
 130  0 public org.w3c.dom.Document createDocument(
 131    String namespaceURI,
 132    String qualifiedName,
 133    org.w3c.dom.DocumentType documentType
 134    ) throws org.w3c.dom.DOMException {
 135  0 DOMDocument document;
 136  0 if (documentType != null) {
 137  0 DOMDocumentType docType = asDocumentType( documentType );
 138  0 document = new DOMDocument( docType );
 139    } else {
 140  0 document = new DOMDocument();
 141    }
 142   
 143  0 document.addElement( createQName( qualifiedName, namespaceURI ) );
 144  0 return document;
 145    }
 146   
 147   
 148    // Implementation methods
 149   
 150  0 protected DOMDocumentType asDocumentType( org.w3c.dom.DocumentType documentType ) {
 151  0 if ( documentType instanceof DOMDocumentType ) {
 152  0 return (DOMDocumentType) documentType;
 153    }
 154    else {
 155  0 return new DOMDocumentType(
 156    documentType.getName(),
 157    documentType.getPublicId(),
 158    documentType.getSystemId()
 159    );
 160    }
 161    }
 162   
 163    }
 164   
 165   
 166   
 167   
 168    /*
 169    * Redistribution and use of this software and associated documentation
 170    * ("Software"), with or without modification, are permitted provided
 171    * that the following conditions are met:
 172    *
 173    * 1. Redistributions of source code must retain copyright
 174    * statements and notices. Redistributions must also contain a
 175    * copy of this document.
 176    *
 177    * 2. Redistributions in binary form must reproduce the
 178    * above copyright notice, this list of conditions and the
 179    * following disclaimer in the documentation and/or other
 180    * materials provided with the distribution.
 181    *
 182    * 3. The name "DOM4J" must not be used to endorse or promote
 183    * products derived from this Software without prior written
 184    * permission of MetaStuff, Ltd. For written permission,
 185    * please contact dom4j-info@metastuff.com.
 186    *
 187    * 4. Products derived from this Software may not be called "DOM4J"
 188    * nor may "DOM4J" appear in their names without prior written
 189    * permission of MetaStuff, Ltd. DOM4J is a registered
 190    * trademark of MetaStuff, Ltd.
 191    *
 192    * 5. Due credit should be given to the DOM4J Project -
 193    * http://www.dom4j.org
 194    *
 195    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
 196    * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 197    * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 198    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 199    * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 200    * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 201    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 202    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 203    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 204    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 205    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 206    * OF THE POSSIBILITY OF SUCH DAMAGE.
 207    *
 208    * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
 209    *
 210    * $Id: DOMDocumentFactory.java,v 1.17 2004/06/25 08:03:35 maartenc Exp $
 211    */