org.apache.batik.dom
Class AbstractDocument

java.lang.Object
  extended byorg.apache.batik.dom.AbstractNode
      extended byorg.apache.batik.dom.AbstractParentNode
          extended byorg.apache.batik.dom.AbstractDocument
All Implemented Interfaces:
org.w3c.dom.Document, org.w3c.dom.events.DocumentEvent, org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.events.EventTarget, ExtendedNode, Localizable, org.w3c.dom.Node, NodeEventTarget, java.io.Serializable
Direct Known Subclasses:
AbstractStylableDocument, GenericDocument

public abstract class AbstractDocument
extends AbstractParentNode
implements org.w3c.dom.Document, org.w3c.dom.events.DocumentEvent, org.w3c.dom.traversal.DocumentTraversal, Localizable

This class implements the Document interface.

See Also:
Serialized Form

Nested Class Summary
protected  class AbstractDocument.IdSoftRef
           
 
Nested classes inherited from class org.apache.batik.dom.AbstractParentNode
AbstractParentNode.ChildNodes, AbstractParentNode.ElementsByTagName, AbstractParentNode.ElementsByTagNameNS
 
Field Summary
protected  DocumentEventSupport documentEventSupport
          The DocumentEventSupport.
protected  java.util.Map elementsById
          The elementsById lists.
protected  java.util.WeakHashMap elementsByTagNames
          The ElementsByTagName lists.
protected  java.util.WeakHashMap elementsByTagNamesNS
          The ElementsByTagNameNS lists.
protected  boolean eventsEnabled
          Whether the event dispatching must be done.
protected  org.w3c.dom.DOMImplementation implementation
          The DOM implementation.
protected  LocalizableSupport localizableSupport
          The localizable support for the error messages.
protected static java.lang.String RESOURCES
          The error messages bundle class name.
protected  TraversalSupport traversalSupport
          The traversal support.
 
Fields inherited from class org.apache.batik.dom.AbstractParentNode
childNodes
 
Fields inherited from class org.apache.batik.dom.AbstractNode
EMPTY_NODE_LIST, eventSupport, ownerDocument
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected AbstractDocument()
          Creates a new document.
  AbstractDocument(org.w3c.dom.DocumentType dt, org.w3c.dom.DOMImplementation impl)
          Creates a new document.
 
Method Summary
 void addIdEntry(org.w3c.dom.Element e, java.lang.String id)
           
protected  void checkChildType(org.w3c.dom.Node n, boolean replace)
          Checks the validity of a node to be inserted.
 org.w3c.dom.Node cloneNode(boolean deep)
          DOM: Implements Node.cloneNode(boolean).
protected  org.w3c.dom.Node copyInto(org.w3c.dom.Node n)
          Copy the fields of the current node into the given node.
 org.w3c.dom.events.Event createEvent(java.lang.String eventType)
          DOM: Implements DocumentEvent.createEvent(String).
 org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)
          DOM: Implements DocumentTraversal.createNodeIterator(Node,int,NodeFilter,boolean).
 org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)
          DOM: Implements DocumentTraversal.createTreeWalker(Node,int,NodeFilter,boolean).
protected  org.w3c.dom.Node deepCopyInto(org.w3c.dom.Node n)
          Deeply copy the fields of the current node into the given node.
protected  org.w3c.dom.Node deepExport(org.w3c.dom.Node n, org.w3c.dom.Document d)
          Deeply exports this node to the given document.
 void detachNodeIterator(org.w3c.dom.traversal.NodeIterator it)
          Detaches the given node iterator from this document.
protected  org.w3c.dom.Node export(org.w3c.dom.Node n, org.w3c.dom.Document d)
          Exports this node to the given document.
 java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args)
          Implements Localizable.formatMessage(String,Object[]).
 org.w3c.dom.Element getChildElementById(org.w3c.dom.Node requestor, java.lang.String id)
          Finds an element that is in the same document fragment as 'requestor' that has 'id'.
protected  AbstractDocument getCurrentDocument()
          Returns the current document.
 org.w3c.dom.DocumentType getDoctype()
          DOM: Implements Document.getDoctype().
 org.w3c.dom.Element getDocumentElement()
          DOM: Implements Document.getDocumentElement().
 org.w3c.dom.Element getElementById(java.lang.String id)
          DOM: Implements Document.getElementById(String).
 AbstractParentNode.ElementsByTagName getElementsByTagName(org.w3c.dom.Node n, java.lang.String ln)
          Returns an ElementsByTagName object from the cache, if any.
 AbstractParentNode.ElementsByTagNameNS getElementsByTagNameNS(org.w3c.dom.Node n, java.lang.String ns, java.lang.String ln)
          Returns an ElementsByTagNameNS object from the cache, if any.
 boolean getEventsEnabled()
          Tests whether the event dispatching must be done.
 org.w3c.dom.DOMImplementation getImplementation()
          DOM: Implements Document.getImplementation().
 java.util.Locale getLocale()
          Implements Localizable.getLocale().
 java.lang.String getNodeName()
          DOM: Implements Node.getNodeName().
 short getNodeType()
          DOM: Implements Node.getNodeType().
protected  org.w3c.dom.Node getRoot(org.w3c.dom.Node n)
           
 org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)
          DOM: Implements Document.importNode(Node,boolean).
 org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep, boolean trimId)
          Imports the given node 'importNode' to this document.
abstract  boolean isId(org.w3c.dom.Attr node)
           
 void nodeToBeRemoved(org.w3c.dom.Node node)
          Notifies this document that a node will be removed.
 void putElementsByTagName(org.w3c.dom.Node n, java.lang.String ln, AbstractParentNode.ElementsByTagName l)
          Puts an ElementsByTagName object in the cache.
 void putElementsByTagNameNS(org.w3c.dom.Node n, java.lang.String ns, java.lang.String ln, AbstractParentNode.ElementsByTagNameNS l)
          Puts an ElementsByTagNameNS object in the cache.
 void removeIdEntry(org.w3c.dom.Element e, java.lang.String id)
          Remove the mapping for element to id
 void setDoctype(org.w3c.dom.DocumentType dt)
          Sets the document type node.
 void setEventsEnabled(boolean b)
          Sets the eventsEnabled property.
 void setLocale(java.util.Locale l)
          Implements Localizable.setLocale(Locale).
 void updateIdEntry(org.w3c.dom.Element e, java.lang.String oldId, java.lang.String newId)
           
 
Methods inherited from class org.apache.batik.dom.AbstractParentNode
appendChild, checkAndRemove, deepExport, fireDOMNodeInsertedEvent, fireDOMNodeInsertedIntoDocumentEvent, fireDOMNodeRemovedEvent, fireDOMNodeRemovedFromDocumentEvent, fireDOMSubtreeModifiedEvent, getChildNodes, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getLastChild, hasChildNodes, insertBefore, nodeAdded, normalize, removeChild, replaceChild
 
Methods inherited from class org.apache.batik.dom.AbstractNode
addEventListener, createDOMException, dispatchEvent, export, fireDOMCharacterDataModifiedEvent, getAttributes, getEventSupport, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getParentNodeEventTarget, getPrefix, getPreviousSibling, hasAttributes, isSupported, newNode, removeEventListener, setNextSibling, setNodeName, setNodeValue, setOwnerDocument, setParentNode, setPrefix, setPreviousSibling, setSpecified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Document
createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getElementsByTagName, getElementsByTagNameNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 
Methods inherited from interface org.apache.batik.dom.ExtendedNode
isReadonly, setReadonly
 

Field Detail

RESOURCES

protected static final java.lang.String RESOURCES
The error messages bundle class name.

See Also:
Constant Field Values

localizableSupport

protected transient LocalizableSupport localizableSupport
The localizable support for the error messages.


implementation

protected transient org.w3c.dom.DOMImplementation implementation
The DOM implementation.


traversalSupport

protected transient TraversalSupport traversalSupport
The traversal support.


documentEventSupport

protected transient DocumentEventSupport documentEventSupport
The DocumentEventSupport.


eventsEnabled

protected transient boolean eventsEnabled
Whether the event dispatching must be done.


elementsByTagNames

protected transient java.util.WeakHashMap elementsByTagNames
The ElementsByTagName lists.


elementsByTagNamesNS

protected transient java.util.WeakHashMap elementsByTagNamesNS
The ElementsByTagNameNS lists.


elementsById

protected transient java.util.Map elementsById
The elementsById lists. This is keyed on 'id'. the entry is either a IdSoftReference to the element or a List of IdSoftReferences (if there is more than one element owned by this document with a particular 'id').

Constructor Detail

AbstractDocument

protected AbstractDocument()
Creates a new document.


AbstractDocument

public AbstractDocument(org.w3c.dom.DocumentType dt,
                        org.w3c.dom.DOMImplementation impl)
Creates a new document.

Method Detail

setLocale

public void setLocale(java.util.Locale l)
Implements Localizable.setLocale(Locale).

Specified by:
setLocale in interface Localizable
Parameters:
l - The locale to set.

getLocale

public java.util.Locale getLocale()
Implements Localizable.getLocale().

Specified by:
getLocale in interface Localizable

formatMessage

public java.lang.String formatMessage(java.lang.String key,
                                      java.lang.Object[] args)
                               throws java.util.MissingResourceException
Implements Localizable.formatMessage(String,Object[]).

Specified by:
formatMessage in interface Localizable
Parameters:
key - The key used to retreive the message from the resource bundle.
args - The objects that compose the message.
Throws:
java.util.MissingResourceException - if the key is not in the bundle.

getEventsEnabled

public boolean getEventsEnabled()
Tests whether the event dispatching must be done.


setEventsEnabled

public void setEventsEnabled(boolean b)
Sets the eventsEnabled property.


getNodeName

public java.lang.String getNodeName()
DOM: Implements Node.getNodeName().

Specified by:
getNodeName in interface org.w3c.dom.Node
Returns:
"#document".

getNodeType

public short getNodeType()
DOM: Implements Node.getNodeType().

Specified by:
getNodeType in interface org.w3c.dom.Node
Returns:
Node.DOCUMENT_NODE

getDoctype

public org.w3c.dom.DocumentType getDoctype()
DOM: Implements Document.getDoctype().

Specified by:
getDoctype in interface org.w3c.dom.Document

setDoctype

public void setDoctype(org.w3c.dom.DocumentType dt)
Sets the document type node.


getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
DOM: Implements Document.getImplementation().

Specified by:
getImplementation in interface org.w3c.dom.Document
Returns:
implementation

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
DOM: Implements Document.getDocumentElement().

Specified by:
getDocumentElement in interface org.w3c.dom.Document

importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode,
                                   boolean deep)
                            throws org.w3c.dom.DOMException
DOM: Implements Document.importNode(Node,boolean).

Specified by:
importNode in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException

importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode,
                                   boolean deep,
                                   boolean trimId)
Imports the given node 'importNode' to this document. It does so deeply if 'deep' is set to true. It will not mark id attributes as id's if 'trimId' is set false. this is used primarily for the clone trees of the 'use' element so they don't clutter the hashtable.


cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
DOM: Implements Node.cloneNode(boolean).

Specified by:
cloneNode in interface org.w3c.dom.Node
Overrides:
cloneNode in class AbstractNode

isId

public abstract boolean isId(org.w3c.dom.Attr node)

getElementById

public org.w3c.dom.Element getElementById(java.lang.String id)
DOM: Implements Document.getElementById(String).

Specified by:
getElementById in interface org.w3c.dom.Document

getChildElementById

public org.w3c.dom.Element getChildElementById(org.w3c.dom.Node requestor,
                                               java.lang.String id)
Finds an element that is in the same document fragment as 'requestor' that has 'id'.


getRoot

protected org.w3c.dom.Node getRoot(org.w3c.dom.Node n)

removeIdEntry

public void removeIdEntry(org.w3c.dom.Element e,
                          java.lang.String id)
Remove the mapping for element to id


addIdEntry

public void addIdEntry(org.w3c.dom.Element e,
                       java.lang.String id)

updateIdEntry

public void updateIdEntry(org.w3c.dom.Element e,
                          java.lang.String oldId,
                          java.lang.String newId)

getElementsByTagName

public AbstractParentNode.ElementsByTagName getElementsByTagName(org.w3c.dom.Node n,
                                                                 java.lang.String ln)
Returns an ElementsByTagName object from the cache, if any.


putElementsByTagName

public void putElementsByTagName(org.w3c.dom.Node n,
                                 java.lang.String ln,
                                 AbstractParentNode.ElementsByTagName l)
Puts an ElementsByTagName object in the cache.


getElementsByTagNameNS

public AbstractParentNode.ElementsByTagNameNS getElementsByTagNameNS(org.w3c.dom.Node n,
                                                                     java.lang.String ns,
                                                                     java.lang.String ln)
Returns an ElementsByTagNameNS object from the cache, if any.


putElementsByTagNameNS

public void putElementsByTagNameNS(org.w3c.dom.Node n,
                                   java.lang.String ns,
                                   java.lang.String ln,
                                   AbstractParentNode.ElementsByTagNameNS l)
Puts an ElementsByTagNameNS object in the cache.


createEvent

public org.w3c.dom.events.Event createEvent(java.lang.String eventType)
                                     throws org.w3c.dom.DOMException
DOM: Implements DocumentEvent.createEvent(String).

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

createNodeIterator

public org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root,
                                                             int whatToShow,
                                                             org.w3c.dom.traversal.NodeFilter filter,
                                                             boolean entityReferenceExpansion)
                                                      throws org.w3c.dom.DOMException
DOM: Implements DocumentTraversal.createNodeIterator(Node,int,NodeFilter,boolean).

Specified by:
createNodeIterator in interface org.w3c.dom.traversal.DocumentTraversal
Throws:
org.w3c.dom.DOMException

createTreeWalker

public org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root,
                                                         int whatToShow,
                                                         org.w3c.dom.traversal.NodeFilter filter,
                                                         boolean entityReferenceExpansion)
                                                  throws org.w3c.dom.DOMException
DOM: Implements DocumentTraversal.createTreeWalker(Node,int,NodeFilter,boolean).

Specified by:
createTreeWalker in interface org.w3c.dom.traversal.DocumentTraversal
Throws:
org.w3c.dom.DOMException

detachNodeIterator

public void detachNodeIterator(org.w3c.dom.traversal.NodeIterator it)
Detaches the given node iterator from this document.


nodeToBeRemoved

public void nodeToBeRemoved(org.w3c.dom.Node node)
Notifies this document that a node will be removed.

Overrides:
nodeToBeRemoved in class AbstractParentNode

getCurrentDocument

protected AbstractDocument getCurrentDocument()
Returns the current document.

Overrides:
getCurrentDocument in class AbstractNode

export

protected org.w3c.dom.Node export(org.w3c.dom.Node n,
                                  org.w3c.dom.Document d)
Exports this node to the given document.

Parameters:
n - The clone node.
d - The destination document.

deepExport

protected org.w3c.dom.Node deepExport(org.w3c.dom.Node n,
                                      org.w3c.dom.Document d)
Deeply exports this node to the given document.

Parameters:
n - The clone node.
d - The destination document.

copyInto

protected org.w3c.dom.Node copyInto(org.w3c.dom.Node n)
Copy the fields of the current node into the given node.

Overrides:
copyInto in class AbstractNode
Parameters:
n - a node of the type of this.

deepCopyInto

protected org.w3c.dom.Node deepCopyInto(org.w3c.dom.Node n)
Deeply copy the fields of the current node into the given node.

Overrides:
deepCopyInto in class AbstractParentNode
Parameters:
n - a node of the type of this.

checkChildType

protected void checkChildType(org.w3c.dom.Node n,
                              boolean replace)
Checks the validity of a node to be inserted.

Overrides:
checkChildType in class AbstractNode


Copyright ? 2005 Apache Software Foundation. All Rights Reserved.