org.apache.batik.dom
Class AbstractDocument

java.lang.Object
  |
  +--org.apache.batik.dom.AbstractNode
        |
        +--org.apache.batik.dom.AbstractParentNode
              |
              +--org.apache.batik.dom.AbstractDocument
All Implemented Interfaces:
Document, DocumentEvent, DocumentTraversal, EventTarget, ExtendedNode, Localizable, Node, NodeEventTarget, java.io.Serializable
Direct Known Subclasses:
GenericDocument, SVGOMDocument

public abstract class AbstractDocument
extends AbstractParentNode
implements Document, DocumentEvent, DocumentTraversal, Localizable

This class implements the Document interface.

See Also:
Serialized Form

Inner 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.WeakHashMap elementsByTagNames
          The ElementsByTagName lists.
protected  java.util.WeakHashMap elementsByTagNamesNS
          The ElementsByTagNameNS lists.
protected  boolean eventsEnabled
          Whether the event dispatching must be done.
protected  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.
protected AbstractDocument(DOMImplementation impl)
          Creates a new document.
 
Method Summary
protected  void checkChildType(Node n, boolean replace)
          Checks the validity of a node to be inserted.
 Node cloneNode(boolean deep)
          DOM: Implements Node.cloneNode(boolean).
protected  Node copyInto(Node n)
          Copy the fields of the current node into the given node.
 Event createEvent(java.lang.String eventType)
          DOM: Implements DocumentEvent.createEvent(String).
 NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
          DOM: Implements DocumentTraversal.createNodeIterator(Node,int,NodeFilter,boolean).
 TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
          DOM: Implements DocumentTraversal.createTreeWalker(Node,int,NodeFilter,boolean).
protected  Node deepCopyInto(Node n)
          Deeply copy the fields of the current node into the given node.
protected  Node deepExport(Node n, Document d)
          Deeply exports this node to the given document.
 void detachNodeIterator(NodeIterator it)
          Detaches the given node iterator from this document.
protected  Node export(Node n, 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[]).
protected  AbstractDocument getCurrentDocument()
          Returns the current document.
 DocumentType getDoctype()
          DOM: Implements Document.getDoctype().
 Element getDocumentElement()
          DOM: Implements Document.getDocumentElement().
 AbstractParentNode.ElementsByTagName getElementsByTagName(Node n, java.lang.String ln)
          Returns an ElementsByTagName object from the cache, if any.
 AbstractParentNode.ElementsByTagNameNS getElementsByTagNameNS(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.
 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().
 Node importNode(Node importedNode, boolean deep)
          DOM: Implements Document.importNode(Node,boolean).
 void nodeToBeRemoved(Node node)
          Notifies this document that a node will be removed.
 void putElementsByTagName(Node n, java.lang.String ln, AbstractParentNode.ElementsByTagName l)
          Puts an ElementsByTagName object in the cache.
 void putElementsByTagNameNS(Node n, java.lang.String ns, java.lang.String ln, AbstractParentNode.ElementsByTagNameNS l)
          Puts an ElementsByTagNameNS object in the cache.
 void setDoctype(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).
 
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, getElementById, 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.

localizableSupport

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

implementation

protected transient 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.
Constructor Detail

AbstractDocument

protected AbstractDocument()
Creates a new document.

AbstractDocument

protected AbstractDocument(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
Following copied from interface: org.apache.batik.i18n.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
Following copied from interface: org.apache.batik.i18n.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 Node
Returns:
"#document".

getNodeType

public short getNodeType()
DOM: Implements Node.getNodeType().
Specified by:
getNodeType in interface Node
Returns:
Node.DOCUMENT_NODE

getDoctype

public DocumentType getDoctype()
DOM: Implements Document.getDoctype().
Specified by:
getDoctype in interface Document

setDoctype

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

getImplementation

public DOMImplementation getImplementation()
DOM: Implements Document.getImplementation().
Specified by:
getImplementation in interface Document
Returns:
implementation

getDocumentElement

public Element getDocumentElement()
DOM: Implements Document.getDocumentElement().
Specified by:
getDocumentElement in interface Document

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
DOM: Implements Document.importNode(Node,boolean).
Specified by:
importNode in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
importedNodeThe - node to import.
deepIf - true, recursively import the subtree under the specified node; if false, import only the node itself, as explained above. This has no effect on Attr , EntityReference, and Notation nodes.
Returns:
The imported node that belongs to this Document.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.

cloneNode

public Node cloneNode(boolean deep)
DOM: Implements Node.cloneNode(boolean).
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class AbstractNode
Following copied from interface: org.w3c.dom.Node
Parameters:
deepIf - true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
Returns:
The duplicate node.

getElementsByTagName

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

putElementsByTagName

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

getElementsByTagNameNS

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

putElementsByTagNameNS

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

createEvent

public Event createEvent(java.lang.String eventType)
                  throws DOMException
DOM: Implements DocumentEvent.createEvent(String).
Specified by:
createEvent in interface DocumentEvent
Following copied from interface: org.w3c.dom.events.DocumentEvent
Parameters:
eventTypeThe - 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 UIEvent would call createEvent with the parameter "UIEvents". The initUIEvent method could then be called on the newly created UIEvent to set the specific type of UIEvent to be dispatched and set its context information.The createEvent method is used in creating Events when it is either inconvenient or unnecessary for the user to create an Event themselves. In cases where the implementation provided Event is insufficient, users may supply their own Event implementations for use with the dispatchEvent method.
Returns:
The newly created Event
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the implementation does not support the type of Event interface requested

createNodeIterator

public NodeIterator createNodeIterator(Node root,
                                       int whatToShow,
                                       NodeFilter filter,
                                       boolean entityReferenceExpansion)
                                throws DOMException
DOM: Implements DocumentTraversal.createNodeIterator(Node,int,NodeFilter,boolean).
Specified by:
createNodeIterator in interface DocumentTraversal
Following copied from interface: org.w3c.dom.traversal.DocumentTraversal
Parameters:
rootThe - node which will be iterated together with its children. The iterator is initially positioned just before this node. The whatToShow flags and the filter, if any, are not considered when setting this position. The root must not be null.
whatToShowThis - flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
filterThe - NodeFilter to be used with this TreeWalker, or null to indicate no filter.
entityReferenceExpansionThe - value of this flag determines whether entity reference nodes are expanded.
Returns:
The newly created NodeIterator.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the specified root is null.

createTreeWalker

public TreeWalker createTreeWalker(Node root,
                                   int whatToShow,
                                   NodeFilter filter,
                                   boolean entityReferenceExpansion)
                            throws DOMException
DOM: Implements DocumentTraversal.createTreeWalker(Node,int,NodeFilter,boolean).
Specified by:
createTreeWalker in interface DocumentTraversal
Following copied from interface: org.w3c.dom.traversal.DocumentTraversal
Parameters:
rootThe - node which will serve as the root for the TreeWalker. The whatToShow flags and the NodeFilter are not considered when setting this value; any node type will be accepted as the root. The currentNode of the TreeWalker is initialized to this node, whether or not it is visible. The root functions as a stopping point for traversal methods that look upward in the document structure, such as parentNode and nextNode. The root must not be null.
whatToShowThis - flag specifies which node types may appear in the logical view of the tree presented by the tree-walker. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
filterThe - NodeFilter to be used with this TreeWalker, or null to indicate no filter.
entityReferenceExpansionIf - this flag is false, the contents of EntityReference nodes are not presented in the logical view.
Returns:
The newly created TreeWalker.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the specified root is null.

detachNodeIterator

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

nodeToBeRemoved

public void nodeToBeRemoved(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 Node export(Node n,
                      Document d)
Exports this node to the given document.
Parameters:
n - The clone node.
d - The destination document.

deepExport

protected Node deepExport(Node n,
                          Document d)
Deeply exports this node to the given document.
Parameters:
n - The clone node.
d - The destination document.

copyInto

protected Node copyInto(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 Node deepCopyInto(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(Node n,
                              boolean replace)
Checks the validity of a node to be inserted.
Overrides:
checkChildType in class AbstractNode


Copyright © 2002 Apache Software Foundation. All Rights Reserved.