org.apache.batik.dom
Class DocumentWrapper

java.lang.Object
  |
  +--org.apache.batik.dom.NodeWrapper
        |
        +--org.apache.batik.dom.DocumentWrapper
All Implemented Interfaces:
Document, DocumentEvent, EventTarget, Node

public class DocumentWrapper
extends NodeWrapper
implements Document, DocumentEvent

This class implements a wrapper for a Document. All the methods of the underlying document are called in a single thread.


Field Summary
protected  DOMImplementationWrapper domImplementationWrapper
          The DOMImplementation wrapper.
protected  java.util.Map nodes
          The node cache.
 
Fields inherited from class org.apache.batik.dom.NodeWrapper
bubblingListeners, capturingListeners, documentWrapper, node
 
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
DocumentWrapper(DOMImplementationWrapper diw, Document doc)
          Creates a new DocumentWrapper object.
 
Method Summary
 Attr createAttribute(java.lang.String name)
          DOM: Implements Document.createAttribute(String).
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          DOM: Implements Document.createAttributeNS(String,String).
protected  Attr createAttrWrapper(Attr a)
          Creates a wrapper for the given Attr.
 CDATASection createCDATASection(java.lang.String data)
          DOM: Implements Document.createCDATASection(String).
protected  CDATASection createCDATASectionWrapper(CDATASection c)
          Creates a wrapper for the given Comment.
 Comment createComment(java.lang.String data)
          DOM: Implements Document.createComment(String).
protected  Comment createCommentWrapper(Comment c)
          Creates a wrapper for the given Comment.
 DocumentFragment createDocumentFragment()
          DOM: Implements Document.createDocumentFragment().
protected  DocumentFragment createDocumentFragmentWrapper(DocumentFragment df)
          Creates a wrapper for the given DocumentFragment.
 Element createElement(java.lang.String tagName)
          DOM: Implements Document.createElement(String).
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          DOM: Implements Document.createElementNS(String,String).
protected  Element createElementWrapper(Element e)
          Creates a wrapper for the given element.
 EntityReference createEntityReference(java.lang.String name)
          DOM: Implements Document.createEntityReference(String).
protected  EntityReference createEntityReferenceWrapper(EntityReference er)
          Creates a wrapper for the given EntityReference.
 Event createEvent(java.lang.String eventType)
          DOM: Implements DocumentEvent.createEvent(String).
 Event createEventWrapper(Event evt)
          Creates an EventWrapper.
protected  NamedNodeMap createNamedNodeMapWrapper(NamedNodeMap nm)
          Creates a wrapper for the given node map.
protected  NodeList createNodeListWrapper(NodeList nl)
          Creates a wrapper for the given node list.
 Node createNodeWrapper(Node n)
          Creates a wrapper for the given node.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          DOM: Implements Document.createProcessingInstruction(String,String).
protected  ProcessingInstruction createProcessingInstructionWrapper(ProcessingInstruction pi)
          Creates a wrapper for the given ProcessingInstruction.
 Text createTextNode(java.lang.String data)
          DOM: Implements Document.createTextNode(String).
protected  Text createTextWrapper(Text t)
          Creates a wrapper for the given Text.
 DocumentType getDoctype()
          DOM: Implements Document.getDoctype().
 Element getDocumentElement()
          DOM: Implements Document.getDocumentElement().
 Element getElementById(java.lang.String elementId)
          DOM: Implements Document.getElementById(String).
 NodeList getElementsByTagName(java.lang.String tagname)
          DOM: Implements Document.getElementsByTagName(String).
 NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          DOM: Implements Document.getElementsByTagNameNS(String,String).
 DOMImplementation getImplementation()
          DOM: Implements Document.getImplementation().
protected  java.lang.Object getNode(java.lang.Object o)
          Returns the node associated with the given object.
 Node importNode(Node importedNode, boolean deep)
          DOM: Implements Document.importNode(Node,boolean).
 void invokeAndWait(java.lang.Runnable r)
          Invokes the given Runnable from the associated RunnableQueue thread.
 void invokeLater(java.lang.Runnable r)
          Invokes the given Runnable from the associated RunnableQueue thread.
 void nodeWrapperFinalized(NodeWrapper nw)
          Called from the finalize() method of the given object.
 
Methods inherited from class org.apache.batik.dom.NodeWrapper
addEventListener, appendChild, cloneNode, dispatchEvent, finalize, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, removeEventListener, replaceChild, setNodeValue, setPrefix
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

nodes

protected java.util.Map nodes
The node cache.

domImplementationWrapper

protected DOMImplementationWrapper domImplementationWrapper
The DOMImplementation wrapper.
Constructor Detail

DocumentWrapper

public DocumentWrapper(DOMImplementationWrapper diw,
                       Document doc)
Creates a new DocumentWrapper object.
Method Detail

nodeWrapperFinalized

public void nodeWrapperFinalized(NodeWrapper nw)
Called from the finalize() method of the given object.

getDoctype

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

getImplementation

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

getDocumentElement

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

createElement

public Element createElement(java.lang.String tagName)
                      throws DOMException
DOM: Implements Document.createElement(String).
Specified by:
createElement in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
tagNameThe - name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createDocumentFragment

public DocumentFragment createDocumentFragment()
DOM: Implements Document.createDocumentFragment().
Specified by:
createDocumentFragment in interface Document
Following copied from interface: org.w3c.dom.Document
Returns:
A new DocumentFragment.

createTextNode

public Text createTextNode(java.lang.String data)
DOM: Implements Document.createTextNode(String).
Specified by:
createTextNode in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
dataThe - data for the node.
Returns:
The new Text object.

createComment

public Comment createComment(java.lang.String data)
DOM: Implements Document.createComment(String).
Specified by:
createComment in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
dataThe - data for the node.
Returns:
The new Comment object.

createCDATASection

public CDATASection createCDATASection(java.lang.String data)
                                throws DOMException
DOM: Implements Document.createCDATASection(String).
Specified by:
createCDATASection in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
dataThe - data for the CDATASection contents.
Returns:
The new CDATASection object.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                         java.lang.String data)
                                                  throws DOMException
DOM: Implements Document.createProcessingInstruction(String,String).
Specified by:
createProcessingInstruction in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
targetThe - target part of the processing instruction.
dataThe - data for the node.
Returns:
The new ProcessingInstruction object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createAttribute

public Attr createAttribute(java.lang.String name)
                     throws DOMException
DOM: Implements Document.createAttribute(String).
Specified by:
createAttribute in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
nameThe - name of the attribute.
Returns:
A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createEntityReference

public EntityReference createEntityReference(java.lang.String name)
                                      throws DOMException
DOM: Implements Document.createEntityReference(String).
Specified by:
createEntityReference in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
nameThe - name of the entity to reference.
Returns:
The new EntityReference object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

getElementsByTagName

public NodeList getElementsByTagName(java.lang.String tagname)
DOM: Implements Document.getElementsByTagName(String).
Specified by:
getElementsByTagName in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
tagnameThe - name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements.

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.

createElementNS

public Element createElementNS(java.lang.String namespaceURI,
                               java.lang.String qualifiedName)
                        throws DOMException
DOM: Implements Document.createElementNS(String,String).
Specified by:
createElementNS in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
namespaceURIThe - namespace URI of the element to create.
qualifiedNameThe - qualified name of the element type to instantiate.
Returns:
A new Element object with the following attributes:AttributeValueNode.nodeName qualifiedNameNode.namespaceURI namespaceURINode.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameElement.tagName qualifiedName
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" .

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
DOM: Implements Document.createAttributeNS(String,String).
Specified by:
createAttributeNS in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
namespaceURIThe - namespace URI of the attribute to create.
qualifiedNameThe - qualified name of the attribute to instantiate.
Returns:
A new Attr object with the following attributes: AttributeValueNode.nodeNamequalifiedName Node.namespaceURInamespaceURI Node.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameAttr.name qualifiedNameNode.nodeValuethe empty string
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace", or if the qualifiedName is "xmlns" and the namespaceURI is different from " http://www.w3.org/2000/xmlns/".

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
DOM: Implements Document.getElementsByTagNameNS(String,String).
Specified by:
getElementsByTagNameNS in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
namespaceURIThe - namespace URI of the elements to match on. The special value "*" matches all namespaces.
localNameThe - local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.

getElementById

public Element getElementById(java.lang.String elementId)
DOM: Implements Document.getElementById(String).
Specified by:
getElementById in interface Document
Following copied from interface: org.w3c.dom.Document
Parameters:
elementIdThe - unique id value for an element.
Returns:
The matching element.

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

createEventWrapper

public Event createEventWrapper(Event evt)
Creates an EventWrapper.

invokeAndWait

public void invokeAndWait(java.lang.Runnable r)
Invokes the given Runnable from the associated RunnableQueue thread.
Overrides:
invokeAndWait in class NodeWrapper

invokeLater

public void invokeLater(java.lang.Runnable r)
Invokes the given Runnable from the associated RunnableQueue thread.
Overrides:
invokeLater in class NodeWrapper

createNodeWrapper

public Node createNodeWrapper(Node n)
Creates a wrapper for the given node.
Overrides:
createNodeWrapper in class NodeWrapper

createElementWrapper

protected Element createElementWrapper(Element e)
Creates a wrapper for the given element.
Overrides:
createElementWrapper in class NodeWrapper

createAttrWrapper

protected Attr createAttrWrapper(Attr a)
Creates a wrapper for the given Attr.
Overrides:
createAttrWrapper in class NodeWrapper

createCDATASectionWrapper

protected CDATASection createCDATASectionWrapper(CDATASection c)
Creates a wrapper for the given Comment.

createCommentWrapper

protected Comment createCommentWrapper(Comment c)
Creates a wrapper for the given Comment.

createEntityReferenceWrapper

protected EntityReference createEntityReferenceWrapper(EntityReference er)
Creates a wrapper for the given EntityReference.

createTextWrapper

protected Text createTextWrapper(Text t)
Creates a wrapper for the given Text.
Overrides:
createTextWrapper in class NodeWrapper

createDocumentFragmentWrapper

protected DocumentFragment createDocumentFragmentWrapper(DocumentFragment df)
Creates a wrapper for the given DocumentFragment.

createProcessingInstructionWrapper

protected ProcessingInstruction createProcessingInstructionWrapper(ProcessingInstruction pi)
Creates a wrapper for the given ProcessingInstruction.

createNodeListWrapper

protected NodeList createNodeListWrapper(NodeList nl)
Creates a wrapper for the given node list.
Overrides:
createNodeListWrapper in class NodeWrapper

createNamedNodeMapWrapper

protected NamedNodeMap createNamedNodeMapWrapper(NamedNodeMap nm)
Creates a wrapper for the given node map.
Overrides:
createNamedNodeMapWrapper in class NodeWrapper

getNode

protected java.lang.Object getNode(java.lang.Object o)
Returns the node associated with the given object.


Copyright © 2001 Apache Software Foundation. All Rights Reserved.