Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public Class DocumentImpl

extends CoreDocumentImpl
implements DocumentTraversal, DocumentEvent, DocumentRange
Class Inheritance
All Implemented Interfaces
org.w3c.dom.ranges.DocumentRange, org.w3c.dom.events.DocumentEvent, org.w3c.dom.traversal.DocumentTraversal
Known Direct Subclasses
com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl, com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
Imports
com.sun.org.apache.xerces.internal.dom.events.EventImpl, .MutationEventImpl, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, .Serializable, java.util.ArrayList, .HashMap, .Hashtable, .List, .Map, .Vector, org.w3c.dom.Attr, .DOMException, .DOMImplementation, .DocumentType, .Element, .NamedNodeMap, .Node, .UserDataHandler, org.w3c.dom.events.DocumentEvent, .Event, .EventException, .EventListener, .MutationEvent, org.w3c.dom.ranges.DocumentRange, .Range, org.w3c.dom.traversal.DocumentTraversal, .NodeFilter, .NodeIterator, .TreeWalker

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 DocumentImpl class also implements the DOM Level 2 DocumentTraversal interface. This interface is comprised of factory methods needed to create NodeIterators and TreeWalkers. The process of creating NodeIterator objects also adds these references to this document. After finishing with an iterator it is important to remove the object using the remove methods in this implementation. This allows the release of the references from the iterator objects to the DOM Nodes.

Note

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

Authors
Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM, Ralf Pfeiffer, IBM
Since
PR-DOM-Level-1-19980818.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
DocumentImpl.EnclosingAttr

NON-DOM INTERNAL: Return object for getEnclosingAttr.

pack-priv class

Field Summary

Modifier and TypeField and Description
protected Map<NodeImpl, List<DocumentImpl.LEntry>>
eventListeners

Table for event listeners registered to this document nodes.

protected List<NodeIterator>
iterators

Iterators

protected boolean
mutationEvents

Bypass mutation events firing.

protected List<Range>
ranges

Ranges

pack-priv DocumentImpl.EnclosingAttr
private static final ObjectStreamField[]
pack-priv static final long
Inherited from com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl:
actualEncodingallowGrammarAccessancestorCheckingchangesdocElementdocTypedomNormalizerencodingerrorCheckingfConfigurationfDocumentURIfFreeNLCachefXPathEvaluatoridentifiersstandaloneversionxmlVersionChanged

Constructor Summary

AccessConstructor and Description
public
DocumentImpl()

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

public
DocumentImpl(boolean grammarAccess)

Constructor.

public
DocumentImpl(DocumentType doctype)

For DOM2 support.

public
DocumentImpl(DocumentType doctype, boolean grammarAccess)

For DOM2 support.

Method Summary

Modifier and TypeMethod and Description
protected void
addEventListener(NodeImpl
node to add listener to
node
,
String
Event name (NOT event group!) to listen for.
type
,
EventListener
Who gets called when event is dispatched
listener
,
boolean
True iff listener is registered on capturing phase rather than at-target or bubbling
useCapture
)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.addEventListener.

Introduced in DOM Level 2.

public Node

Returns:

org.w3c.dom.Node
cloneNode
(boolean
boolean, iff true replicate children
deep
)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.cloneNode.

Implements org.w3c.dom.Node.cloneNode.

Deep-clone a document, including fixing ownerDoc for the cloned children.

protected void
public Event

Returns:

Newly created Event
createEvent
(String
The eventType parameter specifies the type of Event interface to be created. If the Event interface specified is supported by the implementation this method will return a new Event of the interface type requested. If the Event is to be dispatched via the dispatchEvent method the appropriate event init method must be called after creation in order to initialize the Event's values. As an example, a user wishing to synthesize some kind of Event would call createEvent with the parameter "Events". The initEvent method could then be called on the newly created Event to set the specific type of Event to be dispatched and set its context information.
type
)

Implements org.w3c.dom.events.DocumentEvent.createEvent.

Introduced in DOM Level 2.

public NodeIterator
createNodeIterator(Node
The root of the iterator.
root
,
short
The whatToShow mask.
whatToShow
,
NodeFilter
The NodeFilter installed. Null means no filter.
filter
)

NON-DOM extension: Create and return a NodeIterator.

public NodeIterator
createNodeIterator(Node
The root of the iterator.
root
,
int
The whatToShow mask.
whatToShow
,
NodeFilter
The NodeFilter installed. Null means no filter.
filter
,
boolean
true to expand the contents of EntityReference nodes
entityReferenceExpansion
)

Implements org.w3c.dom.traversal.DocumentTraversal.createNodeIterator.

Create and return a NodeIterator.

public Range
createRange()

Implements org.w3c.dom.ranges.DocumentRange.createRange.

This interface can be obtained from the object implementing the Document interface using binding-specific casting methods.

public TreeWalker
createTreeWalker(Node
The root of the iterator.
root
,
short
The whatToShow mask.
whatToShow
,
NodeFilter
The NodeFilter installed. Null means no filter.
filter
)

NON-DOM extension: Create and return a TreeWalker.

public TreeWalker
createTreeWalker(Node
The root of the iterator.
root
,
int
The whatToShow mask.
whatToShow
,
NodeFilter
The NodeFilter installed. Null means no filter.
filter
,
boolean
true to expand the contents of EntityReference nodes
entityReferenceExpansion
)

Implements org.w3c.dom.traversal.DocumentTraversal.createTreeWalker.

Create and return a TreeWalker.

pack-priv void
deletedText(NodeImpl node, int offset, int count)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.deletedText.

A method to be called when some text was deleted from a text node, so that live objects can be notified.

protected void
dispatchAggregateEvents(NodeImpl
node to dispatch to
node
,
DocumentImpl.EnclosingAttr
description of Attr affected by current operation
ea
)

NON-DOM INTERNAL: Convenience wrapper for calling dispatchAggregateEvents when the context was established by savedEnclosingAttr.

protected void
dispatchAggregateEvents(NodeImpl
The node to dispatch to
node
,
AttrImpl
The Attr node (if any) whose value has been changed as a result of the DOM operation. Null if none such.
enclosingAttr
,
String
The String value previously held by the enclosingAttr. Ignored if none such.
oldvalue
,
short
Type of modification to the attr. See MutationEvent.attrChange
change
)

NON-DOM INTERNAL: Generate the "aggregated" post-mutation events DOMAttrModified and DOMSubtreeModified.

protected boolean

Returns:

true if the event's preventDefault() method was invoked by an EventListener; otherwise false.
dispatchEvent
(NodeImpl
node to dispatch to
node
,
Event
the event object to be dispatched to registered EventListeners
event
)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.dispatchEvent.

Introduced in DOM Level 2.

protected void
dispatchEventToSubtree(Node
target node (that was directly inserted or removed)
n
,
Event
event to be sent to that node and its subtree
e
)

NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom...

protected void
dispatchingEventToSubtree(Node
node to dispatch to
n
,
Event
event to be sent to that node and its subtree
e
)

Dispatches event to the target node's descendents recursively

protected List<DocumentImpl.LEntry>
getEventListeners(NodeImpl n)

Retreive event listener registered on a given node

public DOMImplementation
getImplementation()

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.getImplementation.

Implements org.w3c.dom.Document.getImplementation.

Retrieve information describing the abilities of this particular DOM implementation.

pack-priv boolean
getMutationEvents()

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.getMutationEvents.

Returns true if the DOM implementation generates mutation events.

pack-priv void
insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertedNode.

A method to be called when a node has been inserted in the tree.

pack-priv void
insertedText(NodeImpl node, int offset, int count)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertedText.

A method to be called when some text was inserted into a text node, so that live objects can be notified.

pack-priv void
insertingNode(NodeImpl node, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertingNode.

A method to be called when a node is about to be inserted in the tree.

pack-priv void
modifiedAttrValue(AttrImpl attr, String oldvalue)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.modifiedAttrValue.

A method to be called when an attribute value has been modified

pack-priv void
modifiedCharacterData(NodeImpl node, String oldvalue, String value, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.modifiedCharacterData.

A method to be called when a character data node has been modified

pack-priv void
modifyingCharacterData(NodeImpl node, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.modifyingCharacterData.

A method to be called when a character data node has been modified

private void
pack-priv void
removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.removedAttrNode.

A method to be called when an attribute node has been removed

pack-priv void
removedNode(NodeImpl node, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.removedNode.

A method to be called when a node has been removed from the tree.

protected void
removeEventListener(NodeImpl
node to remove listener from
node
,
String
Event name (NOT event group!) to listen for.
type
,
EventListener
Who gets called when event is dispatched
listener
,
boolean
True iff listener is registered on capturing phase rather than at-target or bubbling
useCapture
)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.removeEventListener.

Introduced in DOM Level 2.

pack-priv void
removeNodeIterator(NodeIterator nodeIterator)

This is not called by the developer client.

pack-priv void
removeRange(Range range)

Not a client function.

pack-priv void
removingNode(NodeImpl node, NodeImpl oldChild, boolean replace)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.removingNode.

A method to be called when a node is about to be removed from the tree.

pack-priv void
renamedAttrNode(Attr oldAt, Attr newAt)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.renamedAttrNode.

A method to be called when an attribute node has been renamed

pack-priv void
renamedElement(Element oldEl, Element newEl)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.renamedElement.

A method to be called when an element has been renamed

pack-priv void
replacedCharacterData(NodeImpl node, String oldvalue, String value)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.replacedCharacterData.

A method to be called when a character data node has been replaced

pack-priv void
replacedNode(NodeImpl node)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.replacedNode.

A method to be called when a node has been replaced in the tree.

pack-priv void
replacedText(NodeImpl node)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.replacedText.

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

pack-priv void
replacingData(NodeImpl node)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.replacingData.

A method to be called when character data is about to be replaced in the tree.

pack-priv void
replacingNode(NodeImpl node)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.replacingNode.

A method to be called when a node is about to be replaced in the tree.

protected void

Returns:

either a description of that Attr, or null if none such.
saveEnclosingAttr
(NodeImpl
node to get enclosing attribute for
node
)

NON-DOM INTERNAL: Pre-mutation context check, in preparation for later generating DOMAttrModified events.

pack-priv void
setAttrNode(AttrImpl attr, AttrImpl previous)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.setAttrNode.

A method to be called when an attribute node has been set

protected void
setEventListeners(NodeImpl n, List<DocumentImpl.LEntry> listeners)

Store event listener registered on a given node This is another place where we could use weak references!

pack-priv void
setMutationEvents(boolean set)

Overrides com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.setMutationEvents.

Sets whether the DOM implementation generates mutation events upon operations.

pack-priv void
splitData(Node node, Node newNode, int offset)

A method to be called when a text node has been split, so that live objects can be notified.

private void
Inherited from com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl:
abortadoptNodecallUserDataHandlerscallUserDataHandlerschangedchangescheckDOMNSErrcheckNamespaceWFcheckQNameclearIdentifiersclonecloneNodecreateAttributecreateAttributeNScreateAttributeNScreateCDATASectioncreateCommentcreateDocumentFragmentcreateDocumentTypecreateElementcreateElementDefinitioncreateElementNScreateElementNScreateEntitycreateEntityReferencecreateNotationcreateProcessingInstructioncreateTextNodefreeNodeListCachegetAsyncgetBaseURIgetDoctypegetDocumentElementgetDocumentURIgetDomConfiggetElementByIdgetElementsByTagNamegetElementsByTagNameNSgetEncodinggetErrorCheckinggetFeaturegetIdentifiergetInputEncodinggetNodeListCachegetNodeNamegetNodeNumbergetNodeNumbergetNodeTypegetOwnerDocumentgetStandalonegetStrictErrorCheckinggetTextContentgetUserDatagetUserDatagetUserDataRecordgetVersiongetXmlEncodinggetXmlStandalonegetXmlVersionimportNodeinsertBeforeisKidOKisNormalizeDocRequiredisValidQNameisXML11VersionisXMLNameisXMLVersionChangedloadloadXMLnormalizeDocumentputIdentifierremoveChildremoveIdentifierremoveUserDataTablerenameNodereplaceChildsaveXMLsetAsyncsetDocumentURIsetEncodingsetErrorCheckingsetInputEncodingsetStandalonesetStrictErrorCheckingsetTextContentsetUserDatasetUserDatasetUserDataTablesetVersionsetXmlEncodingsetXmlStandalonesetXmlVersionundeferChildren