org.enhydra.apache.xerces.dom
Class CoreDocumentImpl

java.lang.Object
  |
  +--org.enhydra.apache.xerces.dom.NodeImpl
        |
        +--org.enhydra.apache.xerces.dom.ChildNode
              |
              +--org.enhydra.apache.xerces.dom.ParentNode
                    |
                    +--org.enhydra.apache.xerces.dom.CoreDocumentImpl
All Implemented Interfaces:
Cloneable, Document, EventTarget, Node, NodeList, Serializable
Direct Known Subclasses:
DocumentImpl

public class CoreDocumentImpl
extends ParentNode
implements Document

The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.

The CoreDocumentImpl class only implements the DOM Core. Additional modules are supported by the more complete DocumentImpl subclass.

Note: When any node in the document is serialized, the entire document is serialized along with it.

Since:
PR-DOM-Level-1-19980818.
Version:
 
Author:
Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM, Ralf Pfeiffer, IBM
See Also:
Serialized Form

Field Summary
protected  boolean allowGrammarAccess
          Allow grammar access.
protected  int changes
          Number of alterations made to this document since its creation.
protected  ElementImpl docElement
          Document element.
protected  DocumentTypeImpl docType
          Document type.
protected  String encoding
          Experimental DOM Level 3 feature: Document encoding
protected  boolean errorChecking
          Bypass error checking.
protected  Hashtable identifiers
          Identifiers.
protected static int[] kidOK
          Table for quick check of child insertion.
(package private) static long serialVersionUID
          Serialization version.
protected  boolean standalone
          Experimental DOM Level 3 feature: Document standalone
protected  String version
          Experimental DOM Level 3 feature: Document version
 
Fields inherited from class org.enhydra.apache.xerces.dom.ParentNode
fCachedChild, fCachedChildIndex, fCachedLength, firstChild, ownerDocument
 
Fields inherited from class org.enhydra.apache.xerces.dom.ChildNode
nextSibling, previousSibling
 
Fields inherited from class org.enhydra.apache.xerces.dom.NodeImpl
ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, IGNORABLEWS, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, UNNORMALIZED
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
CoreDocumentImpl()
          NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
CoreDocumentImpl(boolean grammarAccess)
          Constructor.
CoreDocumentImpl(DocumentType doctype)
          For DOM2 support.
CoreDocumentImpl(DocumentType doctype, boolean grammarAccess)
          For DOM2 support.
 
Method Summary
(package private) static void ()
           
protected  void addEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
           
 Node adoptNode(Node source)
          DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document
protected  void changed()
          Denotes that this node has changed.
protected  int changes()
          Returns the number of changes to this node.
 Object clone()
          Clone.
 Node cloneNode(boolean deep)
          Deep-clone a document, including fixing ownerDoc for the cloned children.
protected  void cloneNode(CoreDocumentImpl newdoc, boolean deep)
          internal method to share code with subclass
 Attr createAttribute(String name)
          Factory method; creates an Attribute having this Document as its OwnerDoc.
 Attr createAttributeNS(String namespaceURI, String qualifiedName)
          Introduced in DOM Level 2.
 CDATASection createCDATASection(String data)
          Factory method; creates a CDATASection having this Document as its OwnerDoc.
 Comment createComment(String data)
          Factory method; creates a Comment having this Document as its OwnerDoc.
 DocumentFragment createDocumentFragment()
          Factory method; creates a DocumentFragment having this Document as its OwnerDoc.
 DocumentType createDocumentType(String qualifiedName, String publicID, String systemID)
          NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc.
 Element createElement(String tagName)
          Factory method; creates an Element having this Document as its OwnerDoc.
 ElementDefinitionImpl createElementDefinition(String name)
          NON-DOM Factory method: creates an element definition.
 Element createElementNS(String namespaceURI, String qualifiedName)
          Introduced in DOM Level 2.
 Entity createEntity(String name)
          NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc.
 EntityReference createEntityReference(String name)
          Factory method; creates an EntityReference having this Document as its OwnerDoc.
 Notation createNotation(String name)
          NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc.
 ProcessingInstruction createProcessingInstruction(String target, String data)
          Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.
 Text createTextNode(String data)
          Factory method; creates a Text node having this Document as its OwnerDoc.
(package private)  void deletedText(NodeImpl node, int offset, int count)
          A method to be called when some text was deleted from a text node, so that live objects can be notified.
protected  boolean dispatchEvent(NodeImpl node, Event event)
           
 DocumentType getDoctype()
          For XML, this provides access to the Document Type Definition.
 Element getDocumentElement()
          Convenience method, allowing direct access to the child node which is considered the root of the actual document content.
 String getDocumentURI()
           
 DOMConfiguration getDomConfig()
           
 Element getElementById(String elementId)
          Introduced in DOM Level 2 Returns the Element whose ID is given by elementId.
 NodeList getElementsByTagName(String tagname)
          Return a live collection of all descendent Elements (not just immediate children) having the specified tag name.
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
          Introduced in DOM Level 2.
 String getEncoding()
          DOM Level 3 WD - Experimental.
 boolean getErrorChecking()
          Returns true if the DOM implementation performs error checking.
 Element getIdentifier(String idName)
          Returns a previously registered element with the specified identifier name, or null if no element is registered.
 Enumeration getIdentifiers()
          Returns an enumeration registered of identifier names.
 DOMImplementation getImplementation()
          Retrieve information describing the abilities of this particular DOM implementation.
 String getInputEncoding()
           
(package private)  boolean getMutationEvents()
          Returns true if the DOM implementation generates mutation events.
 String getNodeName()
          Returns the node name.
 short getNodeType()
          Returns the node type.
 Document getOwnerDocument()
          Find the Document that this Node belongs to (the document in whose context the Node was created).
 boolean getStandalone()
          DOM Level 3 WD - Experimental.
 boolean getStrictErrorChecking()
           
protected  Object getUserData(NodeImpl n)
          Retreive user data related to a given node
 String getVersion()
          DOM Level 3 WD - Experimental.
 String getXmlEncoding()
           
 boolean getXmlStandalone()
           
 String getXmlVersion()
           
 Node importNode(Node source, boolean deep)
          Copies a node from another document to this document.
 Node insertBefore(Node newChild, Node refChild)
          Since a Document may contain at most one top-level Element child, and at most one DocumentType declaraction, we need to subclass our add-children methods to implement this constraint.
(package private)  void insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace)
          A method to be called when a node has been inserted in the tree.
(package private)  void insertedText(NodeImpl node, int offset, int count)
          A method to be called when some text was inserted into a text node, so that live objects can be notified.
(package private)  void insertingNode(NodeImpl node, boolean replace)
          A method to be called when a node is about to be inserted in the tree.
protected  boolean isKidOK(Node parent, Node child)
          Uses the kidOK lookup table to check whether the proposed tree structure is legal.
static boolean isXMLName(String s)
          Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class
(package private)  void modifiedAttrValue(AttrImpl attr, String oldvalue)
          A method to be called when an attribute value has been modified
(package private)  void modifiedCharacterData(NodeImpl node, String oldvalue, String value)
          A method to be called when a character data node has been modified
(package private)  void modifyingCharacterData(NodeImpl node)
          A method to be called when a character data node has been modified
 void normalizeDocument()
           
 void putIdentifier(String idName, Element element)
          Registers an identifier name with a specified element node.
 Node removeChild(Node oldChild)
          Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cache REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
(package private)  void removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name)
          A method to be called when an attribute node has been removed
(package private)  void removedNode(NodeImpl node, boolean replace)
          A method to be called when a node has been removed from the tree.
protected  void removeEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
           
 void removeIdentifier(String idName)
          Removes a previously registered element with the specified identifier name.
(package private)  void removingNode(NodeImpl node, NodeImpl oldChild, boolean replace)
          A method to be called when a node is about to be removed from the tree.
 Node renameNode(Node n, String namespaceURI, String qualifiedName)
           
 Node replaceChild(Node newChild, Node oldChild)
          Since we cache the docElement (and, currently, docType), replaceChild has to update the cache REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
(package private)  void replacedNode(NodeImpl node)
          A method to be called when a node has been replaced in the tree.
(package private)  void replacedText(NodeImpl node)
          A method to be called when some text was changed in a text node, so that live objects can be notified.
(package private)  void replacingNode(NodeImpl node)
          A method to be called when a node is about to be replaced in the tree.
(package private)  void setAttrNode(AttrImpl attr, AttrImpl previous)
          A method to be called when an attribute node has been set
 void setDocumentURI(String documentURI)
           
 void setEncoding(String value)
          DOM Level 3 WD - Experimental.
 void setErrorChecking(boolean check)
          Sets whether the DOM implementation performs error checking upon operations.
(package private)  void setMutationEvents(boolean set)
          Sets whether the DOM implementation generates mutation events upon operations.
 void setStandalone(boolean value)
          DOM Level 3 WD - Experimental.
 void setStrictErrorChecking(boolean check)
           
protected  void setUserData(NodeImpl n, Object data)
          Store user data related to a given node This is a place where we could use weak references! Indeed, the node here won't be GC'ed as long as some user data is attached to it, since the userData table will have a reference to the node.
 void setVersion(String value)
          DOM Level 3 WD - Experimental.
 void setXmlStandalone(boolean xmlStandalone)
           
 void setXmlVersion(String xmlVersion)
           
 
Methods inherited from class org.enhydra.apache.xerces.dom.ParentNode
checkNormalizationAfterInsert, checkNormalizationAfterRemove, getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, internalInsertBefore, internalRemoveChild, item, lastChild, lastChild, normalize, ownerDocument, setOwnerDocument, setReadOnly, synchronizeChildren
 
Methods inherited from class org.enhydra.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling, parentNode, previousSibling
 
Methods inherited from class org.enhydra.apache.xerces.dom.NodeImpl
addEventListener, appendChild, compareDocumentPosition, dispatchEvent, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getTextContent, getUserData, getUserData, hasAttributes, hasStringValue, hasStringValue, internalIsIgnorableWhitespace, isDefaultNamespace, isEqualNode, isFirstChild, isFirstChild, isIgnorableWhitespace, isNormalized, isNormalized, isOwned, isOwned, isReadOnly, isReadOnly, isSameNode, isSpecified, isSpecified, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, needsSyncChildren, needsSyncData, needsSyncData, removeEventListener, setNodeValue, setPrefix, setTextContent, setUserData, setUserData, synchronizeData, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setTextContent, setUserData
 

Field Detail

serialVersionUID

static final long serialVersionUID
Serialization version.

docType

protected DocumentTypeImpl docType
Document type.

docElement

protected ElementImpl docElement
Document element.

encoding

protected String encoding
Experimental DOM Level 3 feature: Document encoding

version

protected String version
Experimental DOM Level 3 feature: Document version

standalone

protected boolean standalone
Experimental DOM Level 3 feature: Document standalone

identifiers

protected Hashtable identifiers
Identifiers.

kidOK

protected static int[] kidOK
Table for quick check of child insertion.

changes

protected int changes
Number of alterations made to this document since its creation. Serves as a "dirty bit" so that live objects such as NodeList can recognize when an alteration has been made and discard its cached state information.

Any method that alters the tree structure MUST cause or be accompanied by a call to changed(), to inform it that any outstanding NodeLists may have to be updated.

(Required because NodeList is simultaneously "live" and integer- indexed -- a bad decision in the DOM's design.)

Note that changes which do not affect the tree's structure -- changing the node's name, for example -- do _not_ have to call changed().

Alternative implementation would be to use a cryptographic Digest value rather than a count. This would have the advantage that "harmless" changes (those producing equal() trees) would not force NodeList to resynchronize. Disadvantage is that it's slightly more prone to "false negatives", though that's the difference between "wildly unlikely" and "absurdly unlikely". IF we start maintaining digests, we should consider taking advantage of them. Note: This used to be done a node basis, so that we knew what subtree changed. But since only DeepNodeList really use this today, the gain appears to be really small compared to the cost of having an int on every (parent) node plus having to walk up the tree all the way to the root to mark the branch as changed everytime a node is changed. So we now have a single counter global to the document. It means that some objects may flush their cache more often than necessary, but this makes nodes smaller and only the document needs to be marked as changed.


allowGrammarAccess

protected boolean allowGrammarAccess
Allow grammar access.

errorChecking

protected boolean errorChecking
Bypass error checking.
Constructor Detail

CoreDocumentImpl

public CoreDocumentImpl()
NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.

CoreDocumentImpl

public CoreDocumentImpl(boolean grammarAccess)
Constructor.

CoreDocumentImpl

public CoreDocumentImpl(DocumentType doctype)
For DOM2 support. The createDocument factory method is in DOMImplementation.

CoreDocumentImpl

public CoreDocumentImpl(DocumentType doctype,
                        boolean grammarAccess)
For DOM2 support.
Method Detail

static void ()

getOwnerDocument

public final Document getOwnerDocument()
Description copied from class: ParentNode
Find the Document that this Node belongs to (the document in whose context the Node was created). The Node may or may not currently be part of that Document's actual contents.
Specified by:
getOwnerDocument in interface Node
Overrides:
getOwnerDocument in class ParentNode

getNodeType

public short getNodeType()
Returns the node type.
Specified by:
getNodeType in interface Node
Overrides:
getNodeType in class NodeImpl

getNodeName

public String getNodeName()
Returns the node name.
Specified by:
getNodeName in interface Node
Overrides:
getNodeName in class NodeImpl

cloneNode

public Node cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned children. Note that this requires bypassing the WRONG_DOCUMENT_ERR protection. I've chosen to implement it by calling importNode which is DOM Level 2.
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class ParentNode
Parameters:
deep - boolean, iff true replicate children
Returns:
org.w3c.dom.Node

cloneNode

protected void cloneNode(CoreDocumentImpl newdoc,
                         boolean deep)
internal method to share code with subclass

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Since a Document may contain at most one top-level Element child, and at most one DocumentType declaraction, we need to subclass our add-children methods to implement this constraint. Since appendChild() is implemented as insertBefore(,null), altering the latter fixes both.

While I'm doing so, I've taken advantage of the opportunity to cache documentElement and docType so we don't have to search for them. REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way

Specified by:
insertBefore in interface Node
Overrides:
insertBefore in class ParentNode
Following copied from class: org.enhydra.apache.xerces.dom.ParentNode
Parameters:
newChild - The Node to be moved to our subtree. As a convenience feature, inserting a DocumentNode will instead insert all its children.
refChild - Current child which newChild should be placed immediately before. If refChild is null, the insertion occurs after all existing Nodes, like appendChild().
Throws:
DOMException(HIERARCHY_REQUEST_ERR) - if newChild is of a type that shouldn't be a child of this node, or if newChild is an ancestor of this node.
DOMException(WRONG_DOCUMENT_ERR) - if newChild has a different owner document than we do.
DOMException(NOT_FOUND_ERR) - if refChild is not a child of this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is read-only.

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cache REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
Specified by:
removeChild in interface Node
Overrides:
removeChild in class ParentNode
Following copied from class: org.enhydra.apache.xerces.dom.ParentNode
Returns:
oldChild, in its new state (removed).
Throws:
DOMException(NOT_FOUND_ERR) - if oldChild is not a child of this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is read-only.

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Since we cache the docElement (and, currently, docType), replaceChild has to update the cache REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
Specified by:
replaceChild in interface Node
Overrides:
replaceChild in class ParentNode
Following copied from class: org.enhydra.apache.xerces.dom.ParentNode
Throws:
DOMException(HIERARCHY_REQUEST_ERR) - if newChild is of a type that shouldn't be a child of this node, or if newChild is one of our ancestors.
DOMException(WRONG_DOCUMENT_ERR) - if newChild has a different owner document than we do.
DOMException(NOT_FOUND_ERR) - if oldChild is not a child of this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is read-only.

createAttribute

public Attr createAttribute(String name)
                     throws DOMException
Factory method; creates an Attribute having this Document as its OwnerDoc.
Specified by:
createAttribute in interface Document
Parameters:
name - The name of the attribute. Note that the attribute's value is _not_ established at the factory; remember to set it!
Throws:
DOMException(INVALID_NAME_ERR) - if the attribute name is not acceptable.

createCDATASection

public CDATASection createCDATASection(String data)
                                throws DOMException
Factory method; creates a CDATASection having this Document as its OwnerDoc.
Specified by:
createCDATASection in interface Document
Parameters:
data - The initial contents of the CDATA
Throws:
DOMException(NOT_SUPPORTED_ERR) - for HTML documents. (HTML not yet implemented.)

createComment

public Comment createComment(String data)
Factory method; creates a Comment having this Document as its OwnerDoc.
Specified by:
createComment in interface Document
Parameters:
data - The initial contents of the Comment.

createDocumentFragment

public DocumentFragment createDocumentFragment()
Factory method; creates a DocumentFragment having this Document as its OwnerDoc.
Specified by:
createDocumentFragment in interface Document

createElement

public Element createElement(String tagName)
                      throws DOMException
Factory method; creates an Element having this Document as its OwnerDoc.
Specified by:
createElement in interface Document
Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Throws:
DOMException(INVALID_NAME_ERR) - if the tag name is not acceptable.

createEntityReference

public EntityReference createEntityReference(String name)
                                      throws DOMException
Factory method; creates an EntityReference having this Document as its OwnerDoc.
Specified by:
createEntityReference in interface Document
Parameters:
name - The name of the Entity we wish to refer to
Throws:
DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
                                                  throws DOMException
Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.
Specified by:
createProcessingInstruction in interface Document
Parameters:
target - The target "processor channel"
data - Parameter string to be passed to the target.
Throws:
DOMException(INVALID_NAME_ERR) - if the target name is not acceptable.
DOMException(NOT_SUPPORTED_ERR) - for HTML documents. (HTML not yet implemented.)

createTextNode

public Text createTextNode(String data)
Factory method; creates a Text node having this Document as its OwnerDoc.
Specified by:
createTextNode in interface Document
Parameters:
data - The initial contents of the Text.

getDoctype

public DocumentType getDoctype()
For XML, this provides access to the Document Type Definition. For HTML documents, and XML documents which don't specify a DTD, it will be null.
Specified by:
getDoctype in interface Document

getEncoding

public String getEncoding()
DOM Level 3 WD - Experimental. The encoding of this document (part of XML Declaration)

getVersion

public String getVersion()
DOM Level 3 WD - Experimental. The version of this document (part of XML Declaration)

getStandalone

public boolean getStandalone()
DOM Level 3 WD - Experimental. standalone that specifies whether this document is standalone (part of XML Declaration)

getDocumentElement

public Element getDocumentElement()
Convenience method, allowing direct access to the child node which is considered the root of the actual document content. For HTML, where it is legal to have more than one Element at the top level of the document, we pick the one with the tagName "HTML". For XML there should be only one top-level (HTML not yet supported.)
Specified by:
getDocumentElement in interface Document

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Return a live collection of all descendent Elements (not just immediate children) having the specified tag name.
Specified by:
getElementsByTagName in interface Document
Parameters:
tagname - The type of Element we want to gather. "*" will be taken as a wildcard, meaning "all elements in the document."
See Also:
DeepNodeListImpl

getImplementation

public DOMImplementation getImplementation()
Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.
Specified by:
getImplementation in interface Document

setErrorChecking

public void setErrorChecking(boolean check)
Sets whether the DOM implementation performs error checking upon operations. Turning off error checking only affects the following DOM checks:

Turning off error checking does not turn off the following checks:


setStrictErrorChecking

public void setStrictErrorChecking(boolean check)
Specified by:
setStrictErrorChecking in interface Document

setEncoding

public void setEncoding(String value)
DOM Level 3 WD - Experimental. An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

setVersion

public void setVersion(String value)
DOM Level 3 WD - Experimental. version - An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified

setStandalone

public void setStandalone(boolean value)
DOM Level 3 WD - Experimental. standalone - An attribute specifying, as part of the XML declaration, whether this document is standalone

getErrorChecking

public boolean getErrorChecking()
Returns true if the DOM implementation performs error checking.

getStrictErrorChecking

public boolean getStrictErrorChecking()
Specified by:
getStrictErrorChecking in interface Document

setMutationEvents

void setMutationEvents(boolean set)
Sets whether the DOM implementation generates mutation events upon operations.

getMutationEvents

boolean getMutationEvents()
Returns true if the DOM implementation generates mutation events.

createDocumentType

public DocumentType createDocumentType(String qualifiedName,
                                       String publicID,
                                       String systemID)
                                throws DOMException
NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)
Parameters:
name - The name of the Entity we wish to provide a value for.
Throws:
DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where DTDs are not permitted. (HTML not yet implemented.)

createEntity

public Entity createEntity(String name)
                    throws DOMException
NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)
Parameters:
name - The name of the Entity we wish to provide a value for.
Throws:
DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)

createNotation

public Notation createNotation(String name)
                        throws DOMException
NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)
Parameters:
name - The name of the Notation we wish to describe
Throws:
DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where notations are not permitted. (HTML not yet implemented.)

createElementDefinition

public ElementDefinitionImpl createElementDefinition(String name)
                                              throws DOMException
NON-DOM Factory method: creates an element definition. Element definitions hold default attribute values.

importNode

public Node importNode(Node source,
                       boolean deep)
                throws DOMException
Copies a node from another document to this document. The new nodes are created using this document's factory methods and are populated with the data from the source's accessor methods defined by the DOM interfaces. Its behavior is otherwise similar to that of cloneNode.

According to the DOM specifications, document nodes cannot be imported and a NOT_SUPPORTED_ERR exception is thrown if attempted.

Specified by:
importNode in interface Document

adoptNode

public Node adoptNode(Node source)
               throws DOMException
DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document
Specified by:
adoptNode in interface Document
Parameters:
source - The node to adopt.
See Also:
DocumentImpl.importNode

getElementById

public Element getElementById(String elementId)
Introduced in DOM Level 2 Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.

Note: The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.

Specified by:
getElementById in interface Document
See Also:
getIdentifier(java.lang.String)

putIdentifier

public void putIdentifier(String idName,
                          Element element)
Registers an identifier name with a specified element node. If the identifier is already registered, the new element node replaces the previous node. If the specified element node is null, removeIdentifier() is called.
See Also:
getIdentifier(java.lang.String), removeIdentifier(java.lang.String)

getIdentifier

public Element getIdentifier(String idName)
Returns a previously registered element with the specified identifier name, or null if no element is registered.
See Also:
putIdentifier(java.lang.String, org.w3c.dom.Element), removeIdentifier(java.lang.String)

removeIdentifier

public void removeIdentifier(String idName)
Removes a previously registered element with the specified identifier name.
See Also:
putIdentifier(java.lang.String, org.w3c.dom.Element), getIdentifier(java.lang.String)

getIdentifiers

public Enumeration getIdentifiers()
Returns an enumeration registered of identifier names.

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
                        throws DOMException
Introduced in DOM Level 2.

Creates an element of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

Specified by:
createElementNS in interface Document
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
Element A new Element object with the following attributes:
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
DOMException - NAMESPACE_ERR: Raised if the qualifiedName has a prefix that is "xml" and the namespaceURI is neither null nor an empty string nor "http://www.w3.org/XML/1998/namespace", or if the qualifiedName has a prefix different from "xml" and the namespaceURI is null or an empty string.
Since:
WD-DOM-Level-2-19990923

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
                       throws DOMException
Introduced in DOM Level 2.

Creates an attribute of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

Specified by:
createAttributeNS in interface Document
Parameters:
namespaceURI - The namespace URI of the attribute to create. When it is null or an empty string, this method behaves like createAttribute.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
Attr A new Attr object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
Since:
WD-DOM-Level-2-19990923

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Introduced in DOM Level 2.

Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagNameNS in interface Document
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces. When it is null or an empty string, this method behaves like getElementsByTagName.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
NodeList A new NodeList object containing all the matched Elements.
Since:
WD-DOM-Level-2-19990923

clone

public Object clone()
             throws CloneNotSupportedException
Clone.
Overrides:
clone in class Object

isXMLName

public static boolean isXMLName(String s)
Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class

isKidOK

protected boolean isKidOK(Node parent,
                          Node child)
Uses the kidOK lookup table to check whether the proposed tree structure is legal.

changed

protected void changed()
Denotes that this node has changed.
Overrides:
changed in class NodeImpl

changes

protected int changes()
Returns the number of changes to this node.
Overrides:
changes in class NodeImpl

setUserData

protected void setUserData(NodeImpl n,
                           Object data)
Store user data related to a given node This is a place where we could use weak references! Indeed, the node here won't be GC'ed as long as some user data is attached to it, since the userData table will have a reference to the node.

getUserData

protected Object getUserData(NodeImpl n)
Retreive user data related to a given node

addEventListener

protected void addEventListener(NodeImpl node,
                                String type,
                                EventListener listener,
                                boolean useCapture)

removeEventListener

protected void removeEventListener(NodeImpl node,
                                   String type,
                                   EventListener listener,
                                   boolean useCapture)

dispatchEvent

protected boolean dispatchEvent(NodeImpl node,
                                Event event)

replacedText

void replacedText(NodeImpl node)
A method to be called when some text was changed in a text node, so that live objects can be notified.

deletedText

void deletedText(NodeImpl node,
                 int offset,
                 int count)
A method to be called when some text was deleted from a text node, so that live objects can be notified.

insertedText

void insertedText(NodeImpl node,
                  int offset,
                  int count)
A method to be called when some text was inserted into a text node, so that live objects can be notified.

modifyingCharacterData

void modifyingCharacterData(NodeImpl node)
A method to be called when a character data node has been modified

modifiedCharacterData

void modifiedCharacterData(NodeImpl node,
                           String oldvalue,
                           String value)
A method to be called when a character data node has been modified

insertingNode

void insertingNode(NodeImpl node,
                   boolean replace)
A method to be called when a node is about to be inserted in the tree.

insertedNode

void insertedNode(NodeImpl node,
                  NodeImpl newInternal,
                  boolean replace)
A method to be called when a node has been inserted in the tree.

removingNode

void removingNode(NodeImpl node,
                  NodeImpl oldChild,
                  boolean replace)
A method to be called when a node is about to be removed from the tree.

removedNode

void removedNode(NodeImpl node,
                 boolean replace)
A method to be called when a node has been removed from the tree.

replacingNode

void replacingNode(NodeImpl node)
A method to be called when a node is about to be replaced in the tree.

replacedNode

void replacedNode(NodeImpl node)
A method to be called when a node has been replaced in the tree.

modifiedAttrValue

void modifiedAttrValue(AttrImpl attr,
                       String oldvalue)
A method to be called when an attribute value has been modified

setAttrNode

void setAttrNode(AttrImpl attr,
                 AttrImpl previous)
A method to be called when an attribute node has been set

removedAttrNode

void removedAttrNode(AttrImpl attr,
                     NodeImpl oldOwner,
                     String name)
A method to be called when an attribute node has been removed

getInputEncoding

public String getInputEncoding()
Specified by:
getInputEncoding in interface Document

getXmlEncoding

public String getXmlEncoding()
Specified by:
getXmlEncoding in interface Document

getXmlStandalone

public boolean getXmlStandalone()
Specified by:
getXmlStandalone in interface Document

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
                      throws DOMException
Specified by:
setXmlStandalone in interface Document

getXmlVersion

public String getXmlVersion()
Specified by:
getXmlVersion in interface Document

setXmlVersion

public void setXmlVersion(String xmlVersion)
                   throws DOMException
Specified by:
setXmlVersion in interface Document

getDocumentURI

public String getDocumentURI()
Specified by:
getDocumentURI in interface Document

setDocumentURI

public void setDocumentURI(String documentURI)
Specified by:
setDocumentURI in interface Document

getDomConfig

public DOMConfiguration getDomConfig()
Specified by:
getDomConfig in interface Document

normalizeDocument

public void normalizeDocument()
Specified by:
normalizeDocument in interface Document

renameNode

public Node renameNode(Node n,
                       String namespaceURI,
                       String qualifiedName)
                throws DOMException
Specified by:
renameNode in interface Document


Copyright © 1999 The Apache Software Foundation. All Rights reserved.