Enhydra 5.1 API

org.w3c.tidy
Class DOMDocumentImpl

java.lang.Object
  |
  +--org.w3c.tidy.DOMNodeImpl
        |
        +--org.w3c.tidy.DOMDocumentImpl
All Implemented Interfaces:
Document, Node

public class DOMDocumentImpl
extends DOMNodeImpl
implements Document

DOMDocumentImpl (c) 1998-2000 (W3C) MIT, INRIA, Keio University See Tidy.java for the copyright notice. Derived from HTML Tidy Release 4 Aug 2000

Version:
1.4, 1999/09/04 DOM Support
, 1.5, 1999/10/23 Tidy Release 27 Sep 1999 , 1.6, 1999/11/01 Tidy Release 22 Oct 1999 , 1.7, 1999/12/06 Tidy Release 30 Nov 1999 , 1.8, 2000/01/22 Tidy Release 13 Jan 2000 , 1.9, 2000/06/03 Tidy Release 30 Apr 2000 , 1.10, 2000/07/22 Tidy Release 8 Jul 2000 , 1.11, 2000/08/16 Tidy Release 4 Aug 2000
Author:
Dave Raggett
, Andy Quick (translation to Java)

Field Summary
 
Fields inherited from class org.w3c.tidy.DOMNodeImpl
adaptee
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected DOMDocumentImpl(Node adaptee)
           
 
Method Summary
 Node adoptNode(Node source)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 Attr createAttribute(java.lang.String name)
          Creates an Attr of the given name.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          DOM2 - not implemented.
 CDATASection createCDATASection(java.lang.String data)
          Creates a CDATASection node whose value is the specified string.
 Comment createComment(java.lang.String data)
          Creates a Comment node given the specified string.
 DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 Element createElement(java.lang.String tagName)
          Creates an element of the type specified.
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          DOM2 - not implemented.
 EntityReference createEntityReference(java.lang.String name)
          Creates an EntityReference object.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
 Text createTextNode(java.lang.String data)
          Creates a Text node given the specified string.
 DocumentType getDoctype()
          The Document Type Declaration (see DocumentType) associated with this document.
 Element getDocumentElement()
          This is a convenience attribute that allows direct access to the child node that is the root element of the document.
 Element getElementById(java.lang.String elementId)
          DOM2 - not implemented.
 NodeList getElementsByTagName(java.lang.String tagname)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
 NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          DOM2 - not implemented.
 java.lang.String getEncoding()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 java.lang.String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 boolean getStandalone()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 boolean getStrictErrorChecking()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 java.lang.String getVersion()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 Node importNode(Node importedNode, boolean deep)
          DOM2 - not implemented.
 void setEncoding(java.lang.String encoding)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setStandalone(boolean standalone)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setStrictErrorChecking(boolean strictErrorChecking)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setTagTable(TagTable tt)
           
 void setVersion(java.lang.String version)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 
Methods inherited from class org.w3c.tidy.DOMNodeImpl
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

DOMDocumentImpl

protected DOMDocumentImpl(Node adaptee)
Method Detail

setTagTable

public void setTagTable(TagTable tt)

getNodeName

public java.lang.String getNodeName()
Description copied from interface: Node
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface Node
Overrides:
getNodeName in class DOMNodeImpl
See Also:
Node.getNodeName()

getNodeType

public short getNodeType()
Description copied from interface: Node
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface Node
Overrides:
getNodeType in class DOMNodeImpl
See Also:
Node.getNodeType()

getDoctype

public DocumentType getDoctype()
Description copied from interface: Document
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 2 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.

Specified by:
getDoctype in interface Document
See Also:
Document.getDoctype()

getImplementation

public DOMImplementation getImplementation()
Description copied from interface: Document
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Specified by:
getImplementation in interface Document
See Also:
Document.getImplementation()

getDocumentElement

public Element getDocumentElement()
Description copied from interface: Document
This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".

Specified by:
getDocumentElement in interface Document
See Also:
Document.getDocumentElement()

createElement

public Element createElement(java.lang.String tagName)
                      throws DOMException
Description copied from interface: Document
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS method.

Specified by:
createElement in interface Document
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
See Also:
Document.createElement(java.lang.String)

createDocumentFragment

public DocumentFragment createDocumentFragment()
Description copied from interface: Document
Creates an empty DocumentFragment object.

Specified by:
createDocumentFragment in interface Document
Returns:
A new DocumentFragment.
See Also:
Document.createDocumentFragment()

createTextNode

public Text createTextNode(java.lang.String data)
Description copied from interface: Document
Creates a Text node given the specified string.

Specified by:
createTextNode in interface Document
Returns:
The new Text object.
See Also:
Document.createTextNode(java.lang.String)

createComment

public Comment createComment(java.lang.String data)
Description copied from interface: Document
Creates a Comment node given the specified string.

Specified by:
createComment in interface Document
Returns:
The new Comment object.
See Also:
Document.createComment(java.lang.String)

createCDATASection

public CDATASection createCDATASection(java.lang.String data)
                                throws DOMException
Description copied from interface: Document
Creates a CDATASection node whose value is the specified string.

Specified by:
createCDATASection in interface Document
Returns:
The new CDATASection object.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createCDATASection(java.lang.String)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                         java.lang.String data)
                                                  throws DOMException
Description copied from interface: Document
Creates a ProcessingInstruction node given the specified name and data strings.

Specified by:
createProcessingInstruction in interface Document
Returns:
The new ProcessingInstruction object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createAttribute

public Attr createAttribute(java.lang.String name)
                     throws DOMException
Description copied from interface: Document
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.

Specified by:
createAttribute in interface Document
Returns:
A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
See Also:
Document.createAttribute(java.lang.String)

createEntityReference

public EntityReference createEntityReference(java.lang.String name)
                                      throws DOMException
Description copied from interface: Document
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.

Specified by:
createEntityReference in interface Document
Returns:
The new EntityReference object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createEntityReference(java.lang.String)

getElementsByTagName

public NodeList getElementsByTagName(java.lang.String tagname)
Description copied from interface: Document
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagName in interface Document
Returns:
A new NodeList object containing all the matched Elements.
See Also:
Document.getElementsByTagName(java.lang.String)

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
DOM2 - not implemented.

Specified by:
importNode in interface Document
Returns:
The imported node that belongs to this Document.
Throws:
DOMException

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
DOM2 - not implemented.

Specified by:
createAttributeNS in interface Document
Returns:
A new Attr object with the following attributes: AttributeValueNode.nodeNamequalifiedName Node.namespaceURInamespaceURI Node.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameAttr.name qualifiedNameNode.nodeValuethe empty string
Throws:
DOMException

createElementNS

public Element createElementNS(java.lang.String namespaceURI,
                               java.lang.String qualifiedName)
                        throws DOMException
DOM2 - not implemented.

Specified by:
createElementNS in interface Document
Returns:
A new Element object with the following attributes:AttributeValueNode.nodeName qualifiedNameNode.namespaceURI namespaceURINode.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameElement.tagName qualifiedName
Throws:
DOMException

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
DOM2 - not implemented.

Specified by:
getElementsByTagNameNS in interface Document
Returns:
A new NodeList object containing all the matched Elements.

getElementById

public Element getElementById(java.lang.String elementId)
DOM2 - not implemented.

Specified by:
getElementById in interface Document
Returns:
The matching element.

getEncoding

public java.lang.String getEncoding()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Specified by:
getEncoding in interface Document

setEncoding

public void setEncoding(java.lang.String encoding)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Specified by:
setEncoding in interface Document

getVersion

public java.lang.String getVersion()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Specified by:
getVersion in interface Document

setVersion

public void setVersion(java.lang.String version)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Specified by:
setVersion in interface Document

getStandalone

public boolean getStandalone()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
getStandalone in interface Document

setStandalone

public void setStandalone(boolean standalone)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
setStandalone in interface Document

getStrictErrorChecking

public boolean getStrictErrorChecking()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Specified by:
getStrictErrorChecking in interface Document

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Specified by:
setStrictErrorChecking in interface Document

adoptNode

public Node adoptNode(Node source)
               throws DOMException
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

Changes the ownerDocument of a node, its children, as well as the attached attribute nodes if there are any. If the node has a parent it is first removed from its parent child list. This effectively allows moving a subtree from one document to another. The following list describes the specifics for each type of node.

ATTRIBUTE_NODE
The ownerElement attribute is set to null and the specified flag is set to true on the adopted Attr. The descendants of the source Attr are recursively adopted.
DOCUMENT_FRAGMENT_NODE
The descendants of the source node are recursively adopted.
DOCUMENT_NODE
Document nodes cannot be adopted.
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be adopted.
ELEMENT_NODE
Specified attribute nodes of the source element are adopted, and the generated Attr nodes. Default attributes are discarded, though if the document being adopted into defines default attributes for this element name, those are assigned. The descendants of the source element are recursively adopted.
ENTITY_NODE
Entity nodes cannot be adopted.
ENTITY_REFERENCE_NODE
Only the EntityReference node itself is adopted, the descendants are discarded, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
NOTATION_NODE
Notation nodes cannot be adopted.
PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
These nodes can all be adopted. No specifics.
Should this method simply return null when it fails? How "exceptional" is failure for this method?Stick with raising exceptions only in exceptional circumstances, return null on failure (F2F 19 Jun 2000).Can an entity node really be adopted?No, neither can Notation nodes (Telcon 13 Dec 2000).Does this affect keys and hashCode's of the adopted subtree nodes?If so, what about readonly-ness of key and hashCode?if not, would appendChild affect keys/hashCodes or would it generate exceptions if key's are duplicate? Update: Hashcodes have been dropped. Given that the key is only unique within a document an adopted node needs to be given a new key, but what does it mean for the application?

Specified by:
adoptNode in interface Document
Parameters:
source - The node to move into this document.
Returns:
The adopted node, or null if this operation fails, such as when the source node comes from a different implementation.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the source node is of type DOCUMENT, DOCUMENT_TYPE.
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly.

Enhydra 5.1 API