|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 | +--org.enhydra.apache.xerces.dom.DocumentImpl
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.
Inner Class Summary | |
(package private) class |
DocumentImpl.EnclosingAttr
NON-DOM INTERNAL: Return object for getEnclosingAttr. |
(package private) class |
DocumentImpl.LEntry
|
Field Summary | |
protected Hashtable |
eventListeners
Table for event listeners registered to this document nodes. |
protected Vector |
iterators
Iterators |
protected boolean |
mutationEvents
Bypass mutation events firing. |
protected Vector |
ranges
Ranges |
(package private) DocumentImpl.EnclosingAttr |
savedEnclosingAttr
|
(package private) static long |
serialVersionUID
Serialization version. |
protected Hashtable |
userData
Table for user data attached to this document nodes. |
Fields inherited from class org.enhydra.apache.xerces.dom.CoreDocumentImpl |
allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, identifiers, kidOK, standalone, 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 |
Constructor Summary | |
DocumentImpl()
NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation. |
|
DocumentImpl(boolean grammarAccess)
Constructor. |
|
DocumentImpl(DocumentType doctype)
For DOM2 support. |
|
DocumentImpl(DocumentType doctype,
boolean grammarAccess)
For DOM2 support. |
Method Summary | |
protected void |
addEventListener(NodeImpl node,
String type,
EventListener listener,
boolean useCapture)
Introduced in DOM Level 2. |
Node |
cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned children. |
Event |
createEvent(String type)
Introduced in DOM Level 2. |
NodeIterator |
createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
Create and return a NodeIterator. |
NodeIterator |
createNodeIterator(Node root,
short whatToShow,
NodeFilter filter)
NON-DOM extension: Create and return a NodeIterator. |
Range |
createRange()
|
TreeWalker |
createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
Create and return a TreeWalker. |
TreeWalker |
createTreeWalker(Node root,
short whatToShow,
NodeFilter filter)
NON-DOM extension: Create and return a TreeWalker. |
(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 void |
dispatchAggregateEvents(NodeImpl node,
AttrImpl enclosingAttr,
String oldvalue,
short change)
NON-DOM INTERNAL: Generate the "aggregated" post-mutation events DOMAttrModified and DOMSubtreeModified. |
protected void |
dispatchAggregateEvents(NodeImpl node,
DocumentImpl.EnclosingAttr ea)
NON-DOM INTERNAL: Convenience wrapper for calling dispatchAggregateEvents when the context was established by savedEnclosingAttr . |
protected boolean |
dispatchEvent(NodeImpl node,
Event event)
Introduced in DOM Level 2. |
protected void |
dispatchEventToSubtree(NodeImpl node,
Node n,
Event e)
NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom... |
protected Vector |
getEventListeners(NodeImpl n)
Retreive event listener registered on a given node |
DOMImplementation |
getImplementation()
Retrieve information describing the abilities of this particular DOM implementation. |
(package private) boolean |
getMutationEvents()
Returns true if the DOM implementation generates mutation events. |
protected Object |
getUserData(NodeImpl n)
Retreive user data related to a given node |
(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. |
(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 |
(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)
Introduced in DOM Level 2. |
(package private) void |
removeNodeIterator(NodeIterator nodeIterator)
This is not called by the developer client. |
(package private) void |
removeRange(Range range)
Not a client function. |
(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. |
(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. |
protected void |
saveEnclosingAttr(NodeImpl node)
NON-DOM INTERNAL: Pre-mutation context check, in preparation for later generating DOMAttrModified events. |
(package private) void |
setAttrNode(AttrImpl attr,
AttrImpl previous)
A method to be called when an attribute node has been set |
protected void |
setEventListeners(NodeImpl n,
Vector listeners)
Store event listener registered on a given node This is another place where we could use weak references! Indeed, the node here won't be GC'ed as long as some listener is registered on it, since the eventsListeners table will have a reference to the node. |
(package private) void |
setMutationEvents(boolean set)
Sets whether the DOM implementation generates mutation events upon operations. |
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. |
(package private) 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. |
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 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 |
static final long serialVersionUID
protected Vector iterators
protected Vector ranges
protected Hashtable userData
protected Hashtable eventListeners
protected boolean mutationEvents
DocumentImpl.EnclosingAttr savedEnclosingAttr
Constructor Detail |
public DocumentImpl()
public DocumentImpl(boolean grammarAccess)
public DocumentImpl(DocumentType doctype)
public DocumentImpl(DocumentType doctype, boolean grammarAccess)
Method Detail |
public Node cloneNode(boolean deep)
cloneNode
in class CoreDocumentImpl
deep
- boolean, iff true replicate childrenpublic DOMImplementation getImplementation()
getImplementation
in class CoreDocumentImpl
protected void setUserData(NodeImpl n, Object data)
setUserData
in class CoreDocumentImpl
protected Object getUserData(NodeImpl n)
getUserData
in class CoreDocumentImpl
public NodeIterator createNodeIterator(Node root, short whatToShow, NodeFilter filter)
root
- The root of the iterator.whatToShow
- The whatToShow mask.filter
- The NodeFilter installed. Null means no filter.removeNodeIterator(org.w3c.dom.traversal.NodeIterator)
,
#removeNodeIterators
public NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
createNodeIterator
in interface DocumentTraversal
root
- The root of the iterator.whatToShow
- The whatToShow mask.filter
- The NodeFilter installed. Null means no filter.entityReferenceExpansion
- true to expand the contents of
EntityReference nodesremoveNodeIterator(org.w3c.dom.traversal.NodeIterator)
,
#removeNodeIterators
public TreeWalker createTreeWalker(Node root, short whatToShow, NodeFilter filter)
root
- The root of the iterator.whatToShow
- The whatToShow mask.filter
- The NodeFilter installed. Null means no filter.public TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
createTreeWalker
in interface DocumentTraversal
root
- The root of the iterator.whatToShow
- The whatToShow mask.filter
- The NodeFilter installed. Null means no filter.entityReferenceExpansion
- true to expand the contents of
EntityReference nodesvoid removeNodeIterator(NodeIterator nodeIterator)
This function is called from the NodeIterator#detach().
public Range createRange()
createRange
in interface DocumentRange
void removeRange(Range range)
void replacedText(NodeImpl node)
replacedText
in class CoreDocumentImpl
void deletedText(NodeImpl node, int offset, int count)
deletedText
in class CoreDocumentImpl
void insertedText(NodeImpl node, int offset, int count)
insertedText
in class CoreDocumentImpl
void splitData(Node node, Node newNode, int offset)
public Event createEvent(String type) throws DOMException
Create and return Event objects.
createEvent
in interface DocumentEvent
type
- 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.DOMException
- NOT_SUPPORTED_ERR: Raised if the implementation
does not support the type of Event interface requestedvoid setMutationEvents(boolean set)
setMutationEvents
in class CoreDocumentImpl
boolean getMutationEvents()
getMutationEvents
in class CoreDocumentImpl
protected void setEventListeners(NodeImpl n, Vector listeners)
protected Vector getEventListeners(NodeImpl n)
protected void addEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
Register an event listener with this Node. A listener may be independently registered as both Capturing and Bubbling, but may only be registered once per role; redundant registrations are ignored.
addEventListener
in class CoreDocumentImpl
node
- node to add listener totype
- Event name (NOT event group!) to listen for.listener
- Who gets called when event is dispatcheduseCapture
- True iff listener is registered on
capturing phase rather than at-target or bubblingprotected void removeEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
Deregister an event listener previously registered with this Node. A listener must be independently removed from the Capturing and Bubbling roles. Redundant removals (of listeners not currently registered for this role) are ignored.
removeEventListener
in class CoreDocumentImpl
node
- node to remove listener fromtype
- Event name (NOT event group!) to listen for.listener
- Who gets called when event is dispatcheduseCapture
- True iff listener is registered on
capturing phase rather than at-target or bubblingprotected boolean dispatchEvent(NodeImpl node, Event event)
Distribution engine for DOM Level 2 Events.
Event propagation runs as follows:
Note that registration of handlers during processing of an event does not take effect during this phase of this event; they will not be called until the next time this node is visited by dispatchEvent. On the other hand, removals take effect immediately.
If an event handler itself causes events to be dispatched, they are processed synchronously, before processing resumes on the event which triggered them. Please be aware that this may result in events arriving at listeners "out of order" relative to the actual sequence of requests.
Note that our implementation resets the event's stop/prevent flags when dispatch begins. I believe the DOM's intent is that event objects be redispatchable, though it isn't stated in those terms.
dispatchEvent
in class CoreDocumentImpl
node
- node to dispatch toevent
- the event object to be dispatched to
registered EventListenerspreventDefault()
method was invoked by an EventListener; otherwise false.protected void dispatchEventToSubtree(NodeImpl node, Node n, Event e)
***** At the moment I'm being sloppy and using the normal capture dispatcher on every node. This could be optimized hugely by writing a capture engine that tracks our position in the tree to update the capture chain without repeated chases up to root.
node
- node to dispatch ton
- node which was directly inserted or removede
- event to be sent to that node and its subtreeprotected void dispatchAggregateEvents(NodeImpl node, DocumentImpl.EnclosingAttr ea)
savedEnclosingAttr
.node
- node to dispatch toea
- description of Attr affected by current operationprotected void dispatchAggregateEvents(NodeImpl node, AttrImpl enclosingAttr, String oldvalue, short change)
To manage this, use the "internal" versions of insert and remove with MUTATION_LOCAL, then make an explicit call to this routine at the higher level. Some examples now exist in our code.
node
- The node to dispatch toenclosingAttr
- The Attr node (if any) whose value has been changed
as a result of the DOM operation. Null if none such.oldValue
- The String value previously held by the
enclosingAttr. Ignored if none such.change
- Type of modification to the attr. See
MutationEvent.attrChangeprotected void saveEnclosingAttr(NodeImpl node)
node
- node to get enclosing attribute forvoid modifyingCharacterData(NodeImpl node)
modifyingCharacterData
in class CoreDocumentImpl
void modifiedCharacterData(NodeImpl node, String oldvalue, String value)
modifiedCharacterData
in class CoreDocumentImpl
void insertingNode(NodeImpl node, boolean replace)
insertingNode
in class CoreDocumentImpl
void insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace)
insertedNode
in class CoreDocumentImpl
void removingNode(NodeImpl node, NodeImpl oldChild, boolean replace)
removingNode
in class CoreDocumentImpl
void removedNode(NodeImpl node, boolean replace)
removedNode
in class CoreDocumentImpl
void replacingNode(NodeImpl node)
replacingNode
in class CoreDocumentImpl
void replacedNode(NodeImpl node)
replacedNode
in class CoreDocumentImpl
void modifiedAttrValue(AttrImpl attr, String oldvalue)
modifiedAttrValue
in class CoreDocumentImpl
void setAttrNode(AttrImpl attr, AttrImpl previous)
setAttrNode
in class CoreDocumentImpl
void removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name)
removedAttrNode
in class CoreDocumentImpl
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |