Clover coverage report - dom4j - 1.5
Coverage timestamp: vr sep 3 2004 20:47:03 GMT+01:00
file stats: LOC: 283   Methods: 38
NCLOC: 162   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DOMCDATA.java 0% 0% 0% 0%
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: DOMCDATA.java,v 1.10 2004/06/25 08:03:35 maartenc Exp $
 8    */
 9   
 10    package org.dom4j.dom;
 11   
 12    import org.dom4j.CDATA;
 13    import org.dom4j.Element;
 14    import org.dom4j.tree.DefaultCDATA;
 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>DOMCDATA</code> implements a CDATA Section which
 21    * supports the W3C DOM API.</p>
 22    *
 23    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 24    * @version $Revision: 1.10 $
 25    */
 26    public class DOMCDATA extends DefaultCDATA implements org.w3c.dom.CDATASection {
 27   
 28  0 public DOMCDATA(String text) {
 29  0 super(text);
 30    }
 31   
 32  0 public DOMCDATA(Element parent,String text) {
 33  0 super(parent, text);
 34    }
 35   
 36   
 37   
 38    // org.w3c.dom.Node interface
 39    //-------------------------------------------------------------------------
 40  0 public boolean supports(String feature, String version) {
 41  0 return DOMNodeHelper.supports(this, feature, version);
 42    }
 43   
 44  0 public String getNamespaceURI() {
 45  0 return DOMNodeHelper.getNamespaceURI(this);
 46    }
 47   
 48  0 public String getPrefix() {
 49  0 return DOMNodeHelper.getPrefix(this);
 50    }
 51   
 52  0 public void setPrefix(String prefix) throws DOMException {
 53  0 DOMNodeHelper.setPrefix(this, prefix);
 54    }
 55   
 56  0 public String getLocalName() {
 57  0 return DOMNodeHelper.getLocalName(this);
 58    }
 59   
 60  0 public String getNodeName() {
 61  0 return "#cdata-section";
 62    }
 63   
 64    //already part of API
 65    //
 66    //public short getNodeType();
 67   
 68   
 69   
 70  0 public String getNodeValue() throws DOMException {
 71  0 return DOMNodeHelper.getNodeValue(this);
 72    }
 73   
 74  0 public void setNodeValue(String nodeValue) throws DOMException {
 75  0 DOMNodeHelper.setNodeValue(this, nodeValue);
 76    }
 77   
 78   
 79  0 public org.w3c.dom.Node getParentNode() {
 80  0 return DOMNodeHelper.getParentNode(this);
 81    }
 82   
 83  0 public NodeList getChildNodes() {
 84  0 return DOMNodeHelper.getChildNodes(this);
 85    }
 86   
 87  0 public org.w3c.dom.Node getFirstChild() {
 88  0 return DOMNodeHelper.getFirstChild(this);
 89    }
 90   
 91  0 public org.w3c.dom.Node getLastChild() {
 92  0 return DOMNodeHelper.getLastChild(this);
 93    }
 94   
 95  0 public org.w3c.dom.Node getPreviousSibling() {
 96  0 return DOMNodeHelper.getPreviousSibling(this);
 97    }
 98   
 99  0 public org.w3c.dom.Node getNextSibling() {
 100  0 return DOMNodeHelper.getNextSibling(this);
 101    }
 102   
 103  0 public NamedNodeMap getAttributes() {
 104  0 return null;
 105    }
 106   
 107  0 public Document getOwnerDocument() {
 108  0 return DOMNodeHelper.getOwnerDocument(this);
 109    }
 110   
 111  0 public org.w3c.dom.Node insertBefore(
 112    org.w3c.dom.Node newChild,
 113    org.w3c.dom.Node refChild
 114    ) throws DOMException {
 115  0 checkNewChildNode(newChild);
 116  0 return DOMNodeHelper.insertBefore(this, newChild, refChild);
 117    }
 118   
 119  0 public org.w3c.dom.Node replaceChild(
 120    org.w3c.dom.Node newChild,
 121    org.w3c.dom.Node oldChild
 122    ) throws DOMException {
 123  0 checkNewChildNode(newChild);
 124  0 return DOMNodeHelper.replaceChild(this, newChild, oldChild);
 125    }
 126   
 127  0 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
 128  0 return DOMNodeHelper.removeChild(this, oldChild);
 129    }
 130   
 131  0 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
 132  0 checkNewChildNode(newChild);
 133  0 return DOMNodeHelper.appendChild(this, newChild);
 134    }
 135   
 136  0 private void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
 137  0 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
 138    "CDATASection nodes cannot have children");
 139    }
 140   
 141   
 142  0 public boolean hasChildNodes() {
 143  0 return DOMNodeHelper.hasChildNodes(this);
 144    }
 145   
 146  0 public org.w3c.dom.Node cloneNode(boolean deep) {
 147  0 return DOMNodeHelper.cloneNode(this, deep);
 148    }
 149   
 150  0 public void normalize() {
 151  0 DOMNodeHelper.normalize(this);
 152    }
 153   
 154  0 public boolean isSupported(String feature, String version) {
 155  0 return DOMNodeHelper.isSupported(this, feature, version);
 156    }
 157   
 158  0 public boolean hasAttributes() {
 159  0 return DOMNodeHelper.hasAttributes(this);
 160    }
 161   
 162    // org.w3c.dom.CharacterData interface
 163    //-------------------------------------------------------------------------
 164  0 public String getData() throws DOMException {
 165  0 return DOMNodeHelper.getData(this);
 166    }
 167   
 168  0 public void setData(String data) throws DOMException {
 169  0 DOMNodeHelper.setData(this, data);
 170    }
 171   
 172  0 public int getLength() {
 173  0 return DOMNodeHelper.getLength(this);
 174    }
 175   
 176  0 public String substringData( int offset, int count) throws DOMException {
 177  0 return DOMNodeHelper.substringData(this, offset, count);
 178    }
 179   
 180  0 public void appendData(String arg) throws DOMException {
 181  0 DOMNodeHelper.appendData(this, arg);
 182    }
 183   
 184  0 public void insertData(int offset, String arg) throws DOMException {
 185  0 DOMNodeHelper.insertData(this, offset, arg);
 186    }
 187   
 188  0 public void deleteData(int offset, int count) throws DOMException {
 189  0 DOMNodeHelper.deleteData(this, offset, count);
 190    }
 191   
 192  0 public void replaceData(
 193    int offset, int count, String arg
 194    ) throws DOMException {
 195  0 DOMNodeHelper.replaceData(this, offset, count, arg);
 196    }
 197   
 198    // org.w3c.dom.Text interface
 199    //-------------------------------------------------------------------------
 200  0 public org.w3c.dom.Text splitText(int offset) throws DOMException {
 201  0 if ( isReadOnly() ) {
 202  0 throw new DOMException(
 203    DOMException.NO_MODIFICATION_ALLOWED_ERR,
 204    "CharacterData node is read only: " + this
 205    );
 206    }
 207    else {
 208  0 String text = getText();
 209  0 int length = (text != null) ? text.length() : 0;
 210  0 if ( offset < 0 || offset >= length ) {
 211  0 throw new DOMException(
 212    DOMException.INDEX_SIZE_ERR,
 213    "No text at offset: " + offset
 214    );
 215    }
 216    else {
 217  0 String start = text.substring(0, offset);
 218  0 String rest = text.substring(offset);
 219  0 setText(start);
 220  0 Element parent = getParent();
 221  0 CDATA newText = createCDATA(rest);
 222  0 if ( parent != null ) {
 223  0 parent.add( newText );
 224    }
 225  0 return DOMNodeHelper.asDOMText( newText );
 226    }
 227    }
 228    }
 229   
 230    // Implementation methods
 231    //-------------------------------------------------------------------------
 232  0 protected CDATA createCDATA(String text) {
 233  0 return new DOMCDATA( text );
 234    }
 235    }
 236   
 237   
 238   
 239   
 240    /*
 241    * Redistribution and use of this software and associated documentation
 242    * ("Software"), with or without modification, are permitted provided
 243    * that the following conditions are met:
 244    *
 245    * 1. Redistributions of source code must retain copyright
 246    * statements and notices. Redistributions must also contain a
 247    * copy of this document.
 248    *
 249    * 2. Redistributions in binary form must reproduce the
 250    * above copyright notice, this list of conditions and the
 251    * following disclaimer in the documentation and/or other
 252    * materials provided with the distribution.
 253    *
 254    * 3. The name "DOM4J" must not be used to endorse or promote
 255    * products derived from this Software without prior written
 256    * permission of MetaStuff, Ltd. For written permission,
 257    * please contact dom4j-info@metastuff.com.
 258    *
 259    * 4. Products derived from this Software may not be called "DOM4J"
 260    * nor may "DOM4J" appear in their names without prior written
 261    * permission of MetaStuff, Ltd. DOM4J is a registered
 262    * trademark of MetaStuff, Ltd.
 263    *
 264    * 5. Due credit should be given to the DOM4J Project -
 265    * http://www.dom4j.org
 266    *
 267    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
 268    * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 269    * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 270    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 271    * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 272    * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 273    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 274    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 275    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 276    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 277    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 278    * OF THE POSSIBILITY OF SUCH DAMAGE.
 279    *
 280    * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
 281    *
 282    * $Id: DOMCDATA.java,v 1.10 2004/06/25 08:03:35 maartenc Exp $
 283    */