Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.apache.xerces.dom
Class DocumentImpl

    java.lang.Object
      |
      +--weblogic.apache.xerces.dom.NodeImpl
            |
            +--weblogic.apache.xerces.dom.ChildNode
                  |
                  +--weblogic.apache.xerces.dom.ParentNode
                        |
                        +--weblogic.apache.xerces.dom.CoreDocumentImpl
                              |
                              +--weblogic.apache.xerces.dom.DocumentImpl

Direct Known Subclasses:
  DeferredDocumentImpl, HTMLDocumentImpl, WMLDocumentImpl

public class DocumentImpl
extends CoreDocumentImpl
implements org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.events.DocumentEvent, org.w3c.dom.ranges.DocumentRange

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.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

Author:
  Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM, Ralf Pfeiffer, IBM
See Also:
  Serialized Form

Field Summary
`protected java.util.Hashtable` | `eventListeners` Table for event listeners registered to this document nodes.
`protected java.util.Vector` | `iterators` Iterators
`protected boolean` | `mutationEvents` Bypass mutation events firing.
`protected java.util.Vector` | `ranges` Ranges
`protected java.util.Hashtable` | `userData` Table for user data attached to this document nodes.

Fields inherited from class weblogic.apache.xerces.dom.CoreDocumentImpl
`allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, identifiers, kidOK, standalone, version`

Fields inherited from class weblogic.apache.xerces.dom.ParentNode
`fCachedChild, fCachedChildIndex, fCachedLength, firstChild, ownerDocument`

Fields inherited from class weblogic.apache.xerces.dom.ChildNode
`nextSibling, previousSibling`

Fields inherited from class weblogic.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(org.w3c.dom.DocumentType doctype)` For DOM2 support.
`DocumentImpl(org.w3c.dom.DocumentType doctype, boolean grammarAccess)` For DOM2 support.

Method Summary
`protected void` | `addEventListener(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)` Introduced in DOM Level 2.
`org.w3c.dom.Node` | `cloneNode(boolean deep)` Deep-clone a document, including fixing ownerDoc for the cloned children.
`org.w3c.dom.events.Event` | `createEvent(java.lang.String type)` Introduced in DOM Level 2.
`org.w3c.dom.traversal.NodeIterator` | `createNodeIterator(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)` Create and return a NodeIterator.
`org.w3c.dom.traversal.NodeIterator` | `createNodeIterator(org.w3c.dom.Node root, short whatToShow, org.w3c.dom.traversal.NodeFilter filter)` NON-DOM extension: Create and return a NodeIterator.
`org.w3c.dom.ranges.Range` | `createRange()`
`org.w3c.dom.traversal.TreeWalker` | `createTreeWalker(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)` Create and return a TreeWalker.
`org.w3c.dom.traversal.TreeWalker` | `createTreeWalker(org.w3c.dom.Node root, short whatToShow, org.w3c.dom.traversal.NodeFilter filter)` NON-DOM extension: Create and return a TreeWalker.
`protected void` | `dispatchAggregateEvents(NodeImpl node, AttrImpl enclosingAttr, java.lang.String oldvalue, short change)` NON-DOM INTERNAL: Generate the "aggregated" post-mutation events DOMAttrModified and DOMSubtreeModified.
`protected void` | `dispatchAggregateEvents(NodeImpl node, weblogic.apache.xerces.dom.DocumentImpl.EnclosingAttr ea)` NON-DOM INTERNAL: Convenience wrapper for calling dispatchAggregateEvents when the context was established by `savedEnclosingAttr`.
`protected boolean` | `dispatchEvent(NodeImpl node, org.w3c.dom.events.Event event)` Introduced in DOM Level 2.
`protected void` | `dispatchEventToSubtree(NodeImpl node, org.w3c.dom.Node n, org.w3c.dom.events.Event e)` NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom...
`protected java.util.Vector` | `getEventListeners(NodeImpl n)` Retreive event listener registered on a given node
`org.w3c.dom.DOMImplementation` | `getImplementation()` Retrieve information describing the abilities of this particular DOM implementation.
`protected java.lang.Object` | `getUserData(NodeImpl n)` Retreive user data related to a given node
`protected void` | `removeEventListener(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)` Introduced in DOM Level 2.
`protected void` | `saveEnclosingAttr(NodeImpl node)` NON-DOM INTERNAL: Pre-mutation context check, in preparation for later generating DOMAttrModified events.
`protected void` | `setEventListeners(NodeImpl n, java.util.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.
`protected void` | `setUserData(NodeImpl n, java.lang.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.

Methods inherited from class weblogic.apache.xerces.dom.CoreDocumentImpl
`adoptNode, changed, changes, clone, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElement, createElementDefinition, createElementNS, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getErrorChecking, getIdentifier, getIdentifiers, getNodeName, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getVersion, importNode, insertBefore, isKidOK, isXMLName, putIdentifier, removeChild, removeIdentifier, replaceChild, setEncoding, setErrorChecking, setStandalone, setStrictErrorChecking, setVersion`

Methods inherited from class weblogic.apache.xerces.dom.ParentNode
`getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, item, normalize, setReadOnly, synchronizeChildren`

Methods inherited from class weblogic.apache.xerces.dom.ChildNode
`getNextSibling, getParentNode, getPreviousSibling`

Methods inherited from class weblogic.apache.xerces.dom.NodeImpl
`addEventListener, appendChild, dispatchEvent, getAttributes, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isSupported, removeEventListener, setNodeValue, setPrefix, setUserData, synchronizeData, toString`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### iterators

    protected java.util.Vector iterators

  Iterators

### ranges

    protected java.util.Vector ranges

  Ranges

### userData

    protected java.util.Hashtable userData

  Table for user data attached to this document nodes.

### eventListeners

    protected java.util.Hashtable eventListeners

  Table for event listeners registered to this document nodes.

### mutationEvents

    protected boolean mutationEvents

  Bypass mutation events firing.

Constructor Detail

### DocumentImpl

    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.

### DocumentImpl

    public DocumentImpl(boolean grammarAccess)

  Constructor.

### DocumentImpl

    public DocumentImpl(org.w3c.dom.DocumentType doctype)

  For DOM2 support. The createDocument factory method is in DOMImplementation.

### DocumentImpl

    public DocumentImpl(org.w3c.dom.DocumentType doctype,
                        boolean grammarAccess)

  For DOM2 support.

Method Detail

### cloneNode

    public org.w3c.dom.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.

  Parameters:
    `deep` - boolean, iff true replicate children
  Returns:
    org.w3c.dom.Node
  Overrides:
    cloneNode in class CoreDocumentImpl

### getImplementation

    public org.w3c.dom.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.

  Overrides:
    getImplementation in class CoreDocumentImpl

### setUserData

    protected void setUserData(NodeImpl n,
                               java.lang.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.

  Overrides:
    setUserData in class CoreDocumentImpl

### getUserData

    protected java.lang.Object getUserData(NodeImpl n)

  Retreive user data related to a given node

  Overrides:
    getUserData in class CoreDocumentImpl

### createNodeIterator

    public org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root,
                                                                 short whatToShow,
                                                                 org.w3c.dom.traversal.NodeFilter filter)

  NON-DOM extension: Create and return a NodeIterator. The NodeIterator is added to a list of NodeIterators so that it can be removed to free up the DOM Nodes it references.

  Parameters:
    `root` - The root of the iterator.
    `whatToShow` - The whatToShow mask.
    `filter` - The NodeFilter installed. Null means no filter.
  See Also:
    `#removeNodeIterator`, `#removeNodeIterators`

### createNodeIterator

    public org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root,
                                                                 int whatToShow,
                                                                 org.w3c.dom.traversal.NodeFilter filter,
                                                                 boolean entityReferenceExpansion)

  Create and return a NodeIterator. The NodeIterator is added to a list of NodeIterators so that it can be removed to free up the DOM Nodes it references.
  Specified by:
    createNodeIterator in interface org.w3c.dom.traversal.DocumentTraversal

  Parameters:
    `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 nodes
  See Also:
    `#removeNodeIterator`, `#removeNodeIterators`

### createTreeWalker

    public org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root,
                                                             short whatToShow,
                                                             org.w3c.dom.traversal.NodeFilter filter)

  NON-DOM extension: Create and return a TreeWalker.

  Parameters:
    `root` - The root of the iterator.
    `whatToShow` - The whatToShow mask.
    `filter` - The NodeFilter installed. Null means no filter.

### createTreeWalker

    public org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root,
                                                             int whatToShow,
                                                             org.w3c.dom.traversal.NodeFilter filter,
                                                             boolean entityReferenceExpansion)

  Create and return a TreeWalker.
  Specified by:
    createTreeWalker in interface org.w3c.dom.traversal.DocumentTraversal

  Parameters:
    `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 nodes

### createRange

    public org.w3c.dom.ranges.Range createRange()

  Specified by:
    createRange in interface org.w3c.dom.ranges.DocumentRange

### createEvent

    public org.w3c.dom.events.Event createEvent(java.lang.String type)
                                         throws org.w3c.dom.DOMException

  Introduced in DOM Level 2. Optional.

  Create and return Event objects.

  Specified by:
    createEvent in interface org.w3c.dom.events.DocumentEvent

  Parameters:
    `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.
  Returns:
    Newly created Event
  Throws:
    org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if the implementation does not support the type of Event interface requested

### setEventListeners

    protected void setEventListeners(NodeImpl n,
                                     java.util.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.

### getEventListeners

    protected java.util.Vector getEventListeners(NodeImpl n)

  Retreive event listener registered on a given node

### addEventListener

    protected void addEventListener(NodeImpl node,
                                    java.lang.String type,
                                    org.w3c.dom.events.EventListener listener,
                                    boolean useCapture)

  Introduced in DOM Level 2.

  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.

  Parameters:
    `node` - node to add listener to
    `type` - Event name (NOT event group!) to listen for.
    `listener` - Who gets called when event is dispatched
    `useCapture` - True iff listener is registered on capturing phase rather than at-target or bubbling
  Overrides:
    addEventListener in class CoreDocumentImpl

### removeEventListener

    protected void removeEventListener(NodeImpl node,
                                       java.lang.String type,
                                       org.w3c.dom.events.EventListener listener,
                                       boolean useCapture)

  Introduced in DOM Level 2.

  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.

  Parameters:
    `node` - node to remove listener from
    `type` - Event name (NOT event group!) to listen for.
    `listener` - Who gets called when event is dispatched
    `useCapture` - True iff listener is registered on capturing phase rather than at-target or bubbling
  Overrides:
    removeEventListener in class CoreDocumentImpl

### dispatchEvent

    protected boolean dispatchEvent(NodeImpl node,
                                    org.w3c.dom.events.Event event)

  Introduced in DOM Level 2.

  Distribution engine for DOM Level 2 Events.

  Event propagation runs as follows:

  1. Event is dispatched to a particular target node, which invokes this code. Note that the event's stopPropagation flag is cleared when dispatch begins; thereafter, if it has been set before processing of a node commences, we instead immediately advance to the DEFAULT phase.
  2. The node's ancestors are established as destinations for events. For capture and bubble purposes, node ancestry is determined at the time dispatch starts. If an event handler alters the document tree, that does not change which nodes will be informed of the event.
  3. CAPTURING_PHASE: Ancestors are scanned, root to target, for Capturing listeners. If found, they are invoked (see below).
  4. AT_TARGET: Event is dispatched to NON-CAPTURING listeners on the target node. Note that capturing listeners on this node are _not_ invoked.
  5. BUBBLING_PHASE: Ancestors are scanned, target to root, for non-capturing listeners.
  6. Default processing: Some DOMs have default behaviors bound to specific nodes. If this DOM does, and if the event's preventDefault flag has not been set, we now return to the target node and process its default handler for this event, if any.

  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.

  Parameters:
    `node` - node to dispatch to
    `event` - the event object to be dispatched to registered EventListeners
  Returns:
    true if the event's `preventDefault()` method was invoked by an EventListener; otherwise false.
  Overrides:
    dispatchEvent in class CoreDocumentImpl

### dispatchEventToSubtree

    protected void dispatchEventToSubtree(NodeImpl node,
                                          org.w3c.dom.Node n,
                                          org.w3c.dom.events.Event e)

  NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom... are dispatched to an entire subtree. This is the distribution code therefor. They DO NOT bubble, thanks be, but may be captured.

  ***** 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.

  Parameters:
    `node` - node to dispatch to
    `n` - node which was directly inserted or removed
    `e` - event to be sent to that node and its subtree

### dispatchAggregateEvents

    protected void dispatchAggregateEvents(NodeImpl node,
                                           weblogic.apache.xerces.dom.DocumentImpl.EnclosingAttr ea)

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

  Parameters:
    `node` - node to dispatch to
    `ea` - description of Attr affected by current operation

### dispatchAggregateEvents

    protected void dispatchAggregateEvents(NodeImpl node,
                                           AttrImpl enclosingAttr,
                                           java.lang.String oldvalue,
                                           short change)

  NON-DOM INTERNAL: Generate the "aggregated" post-mutation events DOMAttrModified and DOMSubtreeModified. Both of these should be issued only once for each user-requested mutation operation, even if that involves multiple changes to the DOM. For example, if a DOM operation makes multiple changes to a single Attr before returning, it would be nice to generate only one DOMAttrModified, and multiple changes over larger scope but within a recognizable single subtree might want to generate only one DOMSubtreeModified, sent to their lowest common ancestor.

  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.

  Parameters:
    `node` - The node to dispatch to
    `enclosingAttr` - 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.attrChange

### saveEnclosingAttr

    protected void saveEnclosingAttr(NodeImpl node)

  NON-DOM INTERNAL: Pre-mutation context check, in preparation for later generating DOMAttrModified events. Determines whether this node is within an Attr

  Parameters:
    `node` - node to get enclosing attribute for
  Returns:
    either a description of that Attr, or null if none such.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs70
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference