Clover coverage report - Maven Clover report
Coverage timestamp: Tue Aug 1 2006 15:09:51 CEST
file stats: LOC: 437   Methods: 23
NCLOC: 255   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DOMElementImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Java HTML Tidy - JTidy
 3    * HTML parser and pretty printer
 4    *
 5    * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
 6    * Institute of Technology, Institut National de Recherche en
 7    * Informatique et en Automatique, Keio University). All Rights
 8    * Reserved.
 9    *
 10    * Contributing Author(s):
 11    *
 12    * Dave Raggett <dsr@w3.org>
 13    * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
 14    * Gary L Peskin <garyp@firstech.com> (Java development)
 15    * Sami Lempinen <sami@lempinen.net> (release management)
 16    * Fabrizio Giustina <fgiust at users.sourceforge.net>
 17    *
 18    * The contributing author(s) would like to thank all those who
 19    * helped with testing, bug fixes, and patience. This wouldn't
 20    * have been possible without all of you.
 21    *
 22    * COPYRIGHT NOTICE:
 23    *
 24    * This software and documentation is provided "as is," and
 25    * the copyright holders and contributing author(s) make no
 26    * representations or warranties, express or implied, including
 27    * but not limited to, warranties of merchantability or fitness
 28    * for any particular purpose or that the use of the software or
 29    * documentation will not infringe any third party patents,
 30    * copyrights, trademarks or other rights.
 31    *
 32    * The copyright holders and contributing author(s) will not be
 33    * liable for any direct, indirect, special or consequential damages
 34    * arising out of any use of the software or documentation, even if
 35    * advised of the possibility of such damage.
 36    *
 37    * Permission is hereby granted to use, copy, modify, and distribute
 38    * this source code, or portions hereof, documentation and executables,
 39    * for any purpose, without fee, subject to the following restrictions:
 40    *
 41    * 1. The origin of this source code must not be misrepresented.
 42    * 2. Altered versions must be plainly marked as such and must
 43    * not be misrepresented as being the original source.
 44    * 3. This Copyright notice may not be removed or altered from any
 45    * source or altered source distribution.
 46    *
 47    * The copyright holders and contributing author(s) specifically
 48    * permit, without fee, and encourage the use of this source code
 49    * as a component for supporting the Hypertext Markup Language in
 50    * commercial products. If you use this source code in a product,
 51    * acknowledgment is not required but would be appreciated.
 52    *
 53    */
 54    package org.w3c.tidy;
 55   
 56    import org.w3c.dom.Attr;
 57    import org.w3c.dom.DOMException;
 58    import org.w3c.dom.TypeInfo;
 59   
 60   
 61    /**
 62    * DOMElementImpl.
 63    * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
 64    * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
 65    * @author Fabrizio Giustina
 66    * @version $Revision: 779 $ ($Author: fgiust $)
 67    */
 68    public class DOMElementImpl extends DOMNodeImpl implements org.w3c.dom.Element
 69    {
 70   
 71    /**
 72    * Instantiates a new DOM element.
 73    * @param adaptee Tidy Node.
 74    */
 75  0 protected DOMElementImpl(Node adaptee)
 76    {
 77  0 super(adaptee);
 78    }
 79   
 80    /**
 81    * @see org.w3c.dom.Node#getNodeType
 82    */
 83  0 public short getNodeType()
 84    {
 85  0 return org.w3c.dom.Node.ELEMENT_NODE;
 86    }
 87   
 88    /**
 89    * @see org.w3c.dom.Element#getTagName
 90    */
 91  0 public String getTagName()
 92    {
 93  0 return super.getNodeName();
 94    }
 95   
 96    /**
 97    * @see org.w3c.dom.Element#getAttribute(java.lang.String)
 98    */
 99  0 public String getAttribute(String name)
 100    {
 101  0 if (this.adaptee == null)
 102    {
 103  0 return null;
 104    }
 105   
 106  0 AttVal att = this.adaptee.attributes;
 107  0 while (att != null)
 108    {
 109  0 if (att.attribute.equals(name))
 110    {
 111  0 break;
 112    }
 113  0 att = att.next;
 114    }
 115  0 if (att != null)
 116    {
 117  0 return att.value;
 118    }
 119   
 120  0 return "";
 121    }
 122   
 123    /**
 124    * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
 125    */
 126  0 public void setAttribute(String name, String value) throws DOMException
 127    {
 128  0 if (this.adaptee == null)
 129    {
 130  0 return;
 131    }
 132   
 133  0 AttVal att = this.adaptee.attributes;
 134  0 while (att != null)
 135    {
 136  0 if (att.attribute.equals(name))
 137    {
 138  0 break;
 139    }
 140  0 att = att.next;
 141    }
 142  0 if (att != null)
 143    {
 144  0 att.value = value;
 145    }
 146    else
 147    {
 148  0 att = new AttVal(null, null, '"', name, value);
 149  0 att.dict = AttributeTable.getDefaultAttributeTable().findAttribute(att);
 150  0 if (this.adaptee.attributes == null)
 151    {
 152  0 this.adaptee.attributes = att;
 153    }
 154    else
 155    {
 156  0 att.next = this.adaptee.attributes;
 157  0 this.adaptee.attributes = att;
 158    }
 159    }
 160    }
 161   
 162    /**
 163    * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
 164    */
 165  0 public void removeAttribute(String name) throws DOMException
 166    {
 167  0 if (this.adaptee == null)
 168    {
 169  0 return;
 170    }
 171   
 172  0 AttVal att = this.adaptee.attributes;
 173  0 AttVal pre = null;
 174  0 while (att != null)
 175    {
 176  0 if (att.attribute.equals(name))
 177    {
 178  0 break;
 179    }
 180  0 pre = att;
 181  0 att = att.next;
 182    }
 183  0 if (att != null)
 184    {
 185  0 if (pre == null)
 186    {
 187  0 this.adaptee.attributes = att.next;
 188    }
 189    else
 190    {
 191  0 pre.next = att.next;
 192    }
 193    }
 194    }
 195   
 196    /**
 197    * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
 198    */
 199  0 public org.w3c.dom.Attr getAttributeNode(String name)
 200    {
 201  0 if (this.adaptee == null)
 202    {
 203  0 return null;
 204    }
 205   
 206  0 AttVal att = this.adaptee.attributes;
 207  0 while (att != null)
 208    {
 209  0 if (att.attribute.equals(name))
 210    {
 211  0 break;
 212    }
 213  0 att = att.next;
 214    }
 215  0 if (att != null)
 216    {
 217  0 return att.getAdapter();
 218    }
 219   
 220  0 return null;
 221    }
 222   
 223    /**
 224    * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
 225    */
 226  0 public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr) throws DOMException
 227    {
 228  0 if (newAttr == null)
 229    {
 230  0 return null;
 231    }
 232  0 if (!(newAttr instanceof DOMAttrImpl))
 233    {
 234  0 throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "newAttr not instanceof DOMAttrImpl");
 235    }
 236   
 237  0 DOMAttrImpl newatt = (DOMAttrImpl) newAttr;
 238  0 String name = newatt.avAdaptee.attribute;
 239  0 org.w3c.dom.Attr result = null;
 240   
 241  0 AttVal att = this.adaptee.attributes;
 242  0 while (att != null)
 243    {
 244  0 if (att.attribute.equals(name))
 245    {
 246  0 break;
 247    }
 248  0 att = att.next;
 249    }
 250  0 if (att != null)
 251    {
 252  0 result = att.getAdapter();
 253  0 att.adapter = newAttr;
 254    }
 255    else
 256    {
 257  0 if (this.adaptee.attributes == null)
 258    {
 259  0 this.adaptee.attributes = newatt.avAdaptee;
 260    }
 261    else
 262    {
 263  0 newatt.avAdaptee.next = this.adaptee.attributes;
 264  0 this.adaptee.attributes = newatt.avAdaptee;
 265    }
 266    }
 267  0 return result;
 268    }
 269   
 270    /**
 271    * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
 272    */
 273  0 public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr) throws DOMException
 274    {
 275  0 if (oldAttr == null)
 276    {
 277  0 return null;
 278    }
 279   
 280  0 org.w3c.dom.Attr result = null;
 281  0 AttVal att = this.adaptee.attributes;
 282  0 AttVal pre = null;
 283  0 while (att != null)
 284    {
 285  0 if (att.getAdapter() == oldAttr)
 286    {
 287  0 break;
 288    }
 289  0 pre = att;
 290  0 att = att.next;
 291    }
 292  0 if (att != null)
 293    {
 294  0 if (pre == null)
 295    {
 296  0 this.adaptee.attributes = att.next;
 297    }
 298    else
 299    {
 300  0 pre.next = att.next;
 301    }
 302  0 result = oldAttr;
 303    }
 304    else
 305    {
 306  0 throw new DOMException(DOMException.NOT_FOUND_ERR, "oldAttr not found");
 307    }
 308  0 return result;
 309    }
 310   
 311    /**
 312    * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
 313    */
 314  0 public org.w3c.dom.NodeList getElementsByTagName(String name)
 315    {
 316  0 return new DOMNodeListByTagNameImpl(this.adaptee, name);
 317    }
 318   
 319    /**
 320    * @todo DOM level 2 getOwnerDocument() Not supported. Do nothing.
 321    * @see org.w3c.dom.Element#normalize
 322    */
 323  0 public void normalize()
 324    {
 325    // do nothing
 326    }
 327   
 328    /**
 329    * @todo DOM level 2 getAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 330    * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
 331    */
 332  0 public String getAttributeNS(String namespaceURI, String localName)
 333    {
 334    // DOMException - NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and
 335    // the language exposed through the Document does not support XML Namespaces (such as HTML 4.01).
 336  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 337    }
 338   
 339    /**
 340    * @todo DOM level 2 setAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 341    * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
 342    */
 343  0 public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws org.w3c.dom.DOMException
 344    {
 345  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 346    }
 347   
 348    /**
 349    * @todo DOM level 2 removeAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 350    * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
 351    */
 352  0 public void removeAttributeNS(String namespaceURI, String localName) throws org.w3c.dom.DOMException
 353    {
 354  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 355    }
 356   
 357    /**
 358    * @todo DOM level 2 getAttributeNodeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 359    * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
 360    */
 361  0 public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI, String localName)
 362    {
 363  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 364    }
 365   
 366    /**
 367    * @todo DOM level 2 setAttributeNodeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 368    * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
 369    */
 370  0 public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMException
 371    {
 372  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 373    }
 374   
 375    /**
 376    * @todo DOM level 2 getElementsByTagNameNS() Not supported. Throws NOT_SUPPORTED_ERR.
 377    * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
 378    */
 379  0 public org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI, String localName)
 380    {
 381  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 382    }
 383   
 384    /**
 385    * @todo DOM level 2 hasAttribute() Not supported. Returns false.
 386    * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
 387    */
 388  0 public boolean hasAttribute(String name)
 389    {
 390  0 return false;
 391    }
 392   
 393    /**
 394    * @todo DOM level 2 hasAttribute() Not supported. Returns false.
 395    * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
 396    */
 397  0 public boolean hasAttributeNS(String namespaceURI, String localName)
 398    {
 399  0 return false;
 400    }
 401   
 402    /**
 403    * @todo DOM level 3 getSchemaTypeInfo() Not supported. Returns null.
 404    * @see org.w3c.dom.Element#getSchemaTypeInfo()
 405    */
 406  0 public TypeInfo getSchemaTypeInfo()
 407    {
 408  0 return null;
 409    }
 410   
 411    /**
 412    * @todo DOM level 3 setIdAttribute() Not supported. Throws NOT_SUPPORTED_ERR.
 413    * @see org.w3c.dom.Element#setIdAttribute(java.lang.String, boolean)
 414    */
 415  0 public void setIdAttribute(String name, boolean isId) throws DOMException
 416    {
 417  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 418    }
 419   
 420    /**
 421    * @todo DOM level 3 setIdAttributeNode() Not supported. Throws NOT_SUPPORTED_ERR.
 422    * @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)
 423    */
 424  0 public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException
 425    {
 426  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 427    }
 428   
 429    /**
 430    * @todo DOM level 3 setIdAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
 431    * @see org.w3c.dom.Element#setIdAttributeNS(java.lang.String, java.lang.String, boolean)
 432    */
 433  0 public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException
 434    {
 435  0 throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
 436    }
 437    }