org.apache.batik.dom

Class AbstractDocument

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

This class implements the {@link org.w3c.dom.Document} interface.
Nested Class Summary
protected classAbstractDocument.DocumentConfiguration
DOMConfiguration for this document.
protected classAbstractDocument.DocumentError
DOMError implementation.
protected classAbstractDocument.IdSoftRef
protected classAbstractDocument.XPathExpr
A compiled XPath expression.
protected classAbstractDocument.XPathNodeNSResolver
An XPathNSResolver that uses Node.lookupNamespaceURI.
Field Summary
protected DocumentEventSupportdocumentEventSupport
The DocumentEventSupport.
protected StringdocumentURI
The document URI.
protected AbstractDocument.DocumentConfigurationdomConfig
The DOMConfiguration object for this document.
protected MapelementsById
The elementsById lists.
protected WeakHashMapelementsByTagNames
The ElementsByTagName lists.
protected WeakHashMapelementsByTagNamesNS
The ElementsByTagNameNS lists.
protected booleaneventsEnabled
Whether the event dispatching must be done.
protected DOMImplementationimplementation
The DOM implementation.
protected StringinputEncoding
Input encoding of this document.
protected LocalizableSupportlocalizableSupport
The localizable support for the error messages.
protected static StringRESOURCES
The error messages bundle class name.
protected booleanstrictErrorChecking
Whether strict error checking is in force.
protected TraversalSupporttraversalSupport
The traversal support.
protected XBLManagerxblManager
The XBL manager for this document.
protected StringxmlEncoding
XML encoding of this document.
protected booleanxmlStandalone
Whether this document is standalone.
protected StringxmlVersion
XML version of this document.
Constructor Summary
protected AbstractDocument()
Creates a new document.
AbstractDocument(DocumentType dt, DOMImplementation impl)
Creates a new document.
Method Summary
voidaddIdEntry(Element e, String id)
NodeadoptNode(Node n)
DOM: Implements {@link org.w3c.dom.Document#adoptNode(Node)}.
protected voidadoptNode1(AbstractNode n)
Helper function for {@link #adoptNode(Node)}.
booleancanDispatch(String ns, String eventType)
DOM: Implements {@link org.w3c.dom.events.DocumentEvent#canDispatch(String,String)}.
protected booleancheckChars(String s)
Checks that the characters in the given string are all valid content characters.
protected voidcheckChildType(Node n, boolean replace)
Checks the validity of a node to be inserted.
protected booleancheckName(String s)
Checks that the given string is a valid XML name.
NodecloneNode(boolean deep)
DOM: Implements {@link org.w3c.dom.Node#cloneNode(boolean)}.
protected NodecopyInto(Node n)
Copy the fields of the current node into the given node.
protected DOMErrorcreateDOMError(String type, short severity, String key, Object[] args, Node related, Exception e)
Creates a DOMError object with the given parameters.
EventcreateEvent(String eventType)
DOM: Implements {@link org.w3c.dom.events.DocumentEvent#createEvent(String)}.
XPathExpressioncreateExpression(String expression, XPathNSResolver resolver)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#createExpression(String,XPathNSResolver)}.
NodeIteratorcreateNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
DOM: Implements {@link DocumentTraversal#createNodeIterator(Node,int,NodeFilter,boolean)}.
XPathNSResolvercreateNSResolver(Node n)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#createNSResolver(Node)}.
TreeWalkercreateTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
DOM: Implements {@link DocumentTraversal#createTreeWalker(Node,int,NodeFilter,boolean)}.
XPathExceptioncreateXPathException(short type, String key, Object[] args)
Creates an exception with the appropriate error message.
protected NodedeepCopyInto(Node n)
Deeply copy the fields of the current node into the given node.
protected NodedeepExport(Node n, Document d)
Deeply exports this node to the given document.
voiddetachNodeIterator(NodeIterator it)
Detaches the given node iterator from this document.
Objectevaluate(String expression, Node contextNode, XPathNSResolver resolver, short type, Object result)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#evaluate(String,Node,XPathNSResolver,short,Object)}.
protected Nodeexport(Node n, Document d)
Exports this node to the given document.
StringformatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
ElementgetChildElementById(Node requestor, String id)
Finds an element that is in the same document fragment as 'requestor' that has 'id'.
protected AbstractDocumentgetCurrentDocument()
Returns the current document.
DocumentTypegetDoctype()
DOM: Implements {@link org.w3c.dom.Document#getDoctype()}.
ElementgetDocumentElement()
DOM: Implements {@link org.w3c.dom.Document#getDocumentElement()}.
StringgetDocumentURI()
DOM: Implements {@link org.w3c.dom.Document#getDocumentURI()}.
DOMConfigurationgetDomConfig()
DOM: Implements {@link org.w3c.dom.Document#getDomConfig()}.
ElementgetElementById(String id)
DOM: Implements {@link org.w3c.dom.Document#getElementById(String)}.
ElementsByTagNamegetElementsByTagName(Node n, String ln)
Returns an ElementsByTagName object from the cache, if any.
ElementsByTagNameNSgetElementsByTagNameNS(Node n, String ns, String ln)
Returns an ElementsByTagNameNS object from the cache, if any.
booleangetEventsEnabled()
Tests whether the event dispatching must be done.
DOMImplementationgetImplementation()
DOM: Implements {@link org.w3c.dom.Document#getImplementation()}.
StringgetInputEncoding()
DOM: Implements {@link org.w3c.dom.Document#getInputEncoding()}.
LocalegetLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
StringgetNodeName()
DOM: Implements {@link org.w3c.dom.Node#getNodeName()}.
shortgetNodeType()
DOM: Implements {@link org.w3c.dom.Node#getNodeType()}.
protected NodegetRoot(Node n)
booleangetStrictErrorChecking()
DOM: Implements {@link org.w3c.dom.Document#getStrictErrorChecking()}.
ElementgetXblBoundElement()
Get the bound element whose shadow tree this current node resides in.
NodeListgetXblChildNodes()
Get the list of child nodes of this node in the fully flattened tree.
NodeListgetXblDefinitions()
Get the xbl:definition elements currently binding this element.
NodegetXblFirstChild()
Get the first child node of this node in the fully flattened tree.
ElementgetXblFirstElementChild()
Get the first element child of this node in the fully flattened tree.
NodegetXblLastChild()
Get the last child node of this node in the fully flattened tree.
ElementgetXblLastElementChild()
Get the last element child of this node in the fully flattened tree.
ElementgetXblNextElementSibling()
Get the first element that follows the current node in the xblParentNode's xblChildNodes list.
NodegetXblNextSibling()
Get the node which directly follows the current node in the xblParentNode's xblChildNodes list.
NodegetXblParentNode()
Get the parent of this node in the fully flattened tree.
ElementgetXblPreviousElementSibling()
Get the first element that precedes the current node in the xblParentNode's xblChildNodes list.
NodegetXblPreviousSibling()
Get the node which directly precedes the current node in the xblParentNode's xblChildNodes list.
NodeListgetXblScopedChildNodes()
Get the list of child nodes of this node in the fully flattened tree that are within the same shadow scope.
ElementgetXblShadowTree()
Get the shadow tree of this node.
XBLManagergetXBLManager()
Returns the XBLManager used for this document.
StringgetXmlEncoding()
DOM: Implements {@link org.w3c.dom.Document#getXmlEncoding()}.
booleangetXmlStandalone()
DOM: Implements {@link org.w3c.dom.Document#getXmlStandalone()}.
StringgetXmlVersion()
DOM: Implements {@link org.w3c.dom.Document#getXmlVersion()}.
NodeimportNode(Node importedNode, boolean deep)
DOM: Implements {@link org.w3c.dom.Document#importNode(Node,boolean)}.
NodeimportNode(Node importedNode, boolean deep, boolean trimId)
Imports the given node 'importNode' to this document.
abstract booleanisId(Attr node)
Returns whether the given attribute node is an ID attribute.
voidnodeToBeRemoved(Node node)
Notifies this document that a node will be removed.
voidnormalizeDocument()
DOM: Implements {@link org.w3c.dom.Document#normalizeDocument()}.
protected booleannormalizeDocument(Element e, boolean cdataSections, boolean comments, boolean elementContentWhitepace, boolean namespaceDeclarations, boolean namespaces, boolean splitCdataSections, DOMErrorHandler errorHandler)
Helper function for {@link #normalizeDocument()}.
voidputElementsByTagName(Node n, String ln, ElementsByTagName l)
Puts an ElementsByTagName object in the cache.
voidputElementsByTagNameNS(Node n, String ns, String ln, ElementsByTagNameNS l)
Puts an ElementsByTagNameNS object in the cache.
voidremoveIdEntry(Element e, String id)
Remove the mapping for element to id
NoderenameNode(Node n, String ns, String qn)
DOM: Implements {@link org.w3c.dom.Document#renameNode(Node,String,String)}.
voidsetDoctype(DocumentType dt)
Sets the document type node.
voidsetDocumentInputEncoding(String ie)
Sets the input encoding that was used when the document was being parsed.
voidsetDocumentURI(String uri)
DOM: Implements {@link org.w3c.dom.Document#setDocumentURI(String)}.
voidsetDocumentXmlEncoding(String xe)
Sets the XML encoding that was found in the XML prolog.
voidsetEventsEnabled(boolean b)
Sets the eventsEnabled property.
voidsetLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
voidsetStrictErrorChecking(boolean b)
DOM: Implements {@link org.w3c.dom.Document#setStrictErrorChecking(boolean)}.
voidsetTextContent(String s)
DOM: Implements {@link org.w3c.dom.Node#setTextContent(String)}.
voidsetXBLManager(XBLManager m)
Sets the XBLManager used for this document.
voidsetXmlStandalone(boolean b)
DOM: Implements {@link org.w3c.dom.Document#setXmlStandalone(boolean)}.
voidsetXmlVersion(String v)
DOM: Implements {@link org.w3c.dom.Document#setXmlVersion(String)}.
protected booleansplitCdata(Element e, Node n, DOMErrorHandler errorHandler)
Splits the given CDATA node if required.
voidupdateIdEntry(Element e, String oldId, String newId)

Field Detail

documentEventSupport

protected transient DocumentEventSupport documentEventSupport
The DocumentEventSupport.

documentURI

protected String documentURI
The document URI.

domConfig

protected AbstractDocument.DocumentConfiguration domConfig
The DOMConfiguration object for this document.

elementsById

protected transient 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').

elementsByTagNames

protected transient WeakHashMap elementsByTagNames
The ElementsByTagName lists.

elementsByTagNamesNS

protected transient WeakHashMap elementsByTagNamesNS
The ElementsByTagNameNS lists.

eventsEnabled

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

implementation

protected transient DOMImplementation implementation
The DOM implementation.

inputEncoding

protected String inputEncoding
Input encoding of this document.

localizableSupport

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

RESOURCES

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

strictErrorChecking

protected boolean strictErrorChecking
Whether strict error checking is in force.

traversalSupport

protected transient TraversalSupport traversalSupport
The traversal support.

xblManager

protected transient XBLManager xblManager
The XBL manager for this document.

xmlEncoding

protected String xmlEncoding
XML encoding of this document.

xmlStandalone

protected boolean xmlStandalone
Whether this document is standalone.

xmlVersion

protected String xmlVersion
XML version of this document.

Constructor Detail

AbstractDocument

protected AbstractDocument()
Creates a new document.

AbstractDocument

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

Method Detail

addIdEntry

public void addIdEntry(Element e, String id)

adoptNode

public Node adoptNode(Node n)
DOM: Implements {@link org.w3c.dom.Document#adoptNode(Node)}.

adoptNode1

protected void adoptNode1(AbstractNode n)
Helper function for {@link #adoptNode(Node)}.

canDispatch

public boolean canDispatch(String ns, String eventType)
DOM: Implements {@link org.w3c.dom.events.DocumentEvent#canDispatch(String,String)}.

checkChars

protected boolean checkChars(String s)
Checks that the characters in the given string are all valid content characters.

checkChildType

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

checkName

protected boolean checkName(String s)
Checks that the given string is a valid XML name.

cloneNode

public Node cloneNode(boolean deep)
DOM: Implements {@link org.w3c.dom.Node#cloneNode(boolean)}.

copyInto

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

Parameters: n a node of the type of this.

createDOMError

protected DOMError createDOMError(String type, short severity, String key, Object[] args, Node related, Exception e)
Creates a DOMError object with the given parameters.

createEvent

public Event createEvent(String eventType)
DOM: Implements {@link org.w3c.dom.events.DocumentEvent#createEvent(String)}.

createExpression

public XPathExpression createExpression(String expression, XPathNSResolver resolver)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#createExpression(String,XPathNSResolver)}.

createNodeIterator

public NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
DOM: Implements {@link DocumentTraversal#createNodeIterator(Node,int,NodeFilter,boolean)}.

createNSResolver

public XPathNSResolver createNSResolver(Node n)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#createNSResolver(Node)}.

createTreeWalker

public TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion)
DOM: Implements {@link DocumentTraversal#createTreeWalker(Node,int,NodeFilter,boolean)}.

createXPathException

public XPathException createXPathException(short type, String key, Object[] args)
Creates an exception with the appropriate error message.

deepCopyInto

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

Parameters: n a node of the type of this.

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.

detachNodeIterator

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

evaluate

public Object evaluate(String expression, Node contextNode, XPathNSResolver resolver, short type, Object result)
DOM: Implements {@link org.w3c.dom.xpath.XPathEvaluator#evaluate(String,Node,XPathNSResolver,short,Object)}.

export

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

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

formatMessage

public String formatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.

getChildElementById

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

getCurrentDocument

protected AbstractDocument getCurrentDocument()
Returns the current document.

getDoctype

public DocumentType getDoctype()
DOM: Implements {@link org.w3c.dom.Document#getDoctype()}.

getDocumentElement

public Element getDocumentElement()
DOM: Implements {@link org.w3c.dom.Document#getDocumentElement()}.

getDocumentURI

public String getDocumentURI()
DOM: Implements {@link org.w3c.dom.Document#getDocumentURI()}.

getDomConfig

public DOMConfiguration getDomConfig()
DOM: Implements {@link org.w3c.dom.Document#getDomConfig()}.

getElementById

public Element getElementById(String id)
DOM: Implements {@link org.w3c.dom.Document#getElementById(String)}.

getElementsByTagName

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

getElementsByTagNameNS

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

getEventsEnabled

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

getImplementation

public DOMImplementation getImplementation()
DOM: Implements {@link org.w3c.dom.Document#getImplementation()}.

Returns: {@link #implementation}

getInputEncoding

public String getInputEncoding()
DOM: Implements {@link org.w3c.dom.Document#getInputEncoding()}.

getLocale

public Locale getLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.

getNodeName

public String getNodeName()
DOM: Implements {@link org.w3c.dom.Node#getNodeName()}.

Returns: "#document".

getNodeType

public short getNodeType()
DOM: Implements {@link org.w3c.dom.Node#getNodeType()}.

Returns: {@link org.w3c.dom.Node#DOCUMENT_NODE}

getRoot

protected Node getRoot(Node n)

getStrictErrorChecking

public boolean getStrictErrorChecking()
DOM: Implements {@link org.w3c.dom.Document#getStrictErrorChecking()}.

getXblBoundElement

public Element getXblBoundElement()
Get the bound element whose shadow tree this current node resides in.

getXblChildNodes

public NodeList getXblChildNodes()
Get the list of child nodes of this node in the fully flattened tree.

getXblDefinitions

public NodeList getXblDefinitions()
Get the xbl:definition elements currently binding this element.

getXblFirstChild

public Node getXblFirstChild()
Get the first child node of this node in the fully flattened tree.

getXblFirstElementChild

public Element getXblFirstElementChild()
Get the first element child of this node in the fully flattened tree.

getXblLastChild

public Node getXblLastChild()
Get the last child node of this node in the fully flattened tree.

getXblLastElementChild

public Element getXblLastElementChild()
Get the last element child of this node in the fully flattened tree.

getXblNextElementSibling

public Element getXblNextElementSibling()
Get the first element that follows the current node in the xblParentNode's xblChildNodes list.

getXblNextSibling

public Node getXblNextSibling()
Get the node which directly follows the current node in the xblParentNode's xblChildNodes list.

getXblParentNode

public Node getXblParentNode()
Get the parent of this node in the fully flattened tree.

getXblPreviousElementSibling

public Element getXblPreviousElementSibling()
Get the first element that precedes the current node in the xblParentNode's xblChildNodes list.

getXblPreviousSibling

public Node getXblPreviousSibling()
Get the node which directly precedes the current node in the xblParentNode's xblChildNodes list.

getXblScopedChildNodes

public NodeList getXblScopedChildNodes()
Get the list of child nodes of this node in the fully flattened tree that are within the same shadow scope.

getXblShadowTree

public Element getXblShadowTree()
Get the shadow tree of this node.

getXBLManager

public XBLManager getXBLManager()
Returns the XBLManager used for this document.

getXmlEncoding

public String getXmlEncoding()
DOM: Implements {@link org.w3c.dom.Document#getXmlEncoding()}.

getXmlStandalone

public boolean getXmlStandalone()
DOM: Implements {@link org.w3c.dom.Document#getXmlStandalone()}.

getXmlVersion

public String getXmlVersion()
DOM: Implements {@link org.w3c.dom.Document#getXmlVersion()}.

importNode

public Node importNode(Node importedNode, boolean deep)
DOM: Implements {@link org.w3c.dom.Document#importNode(Node,boolean)}.

importNode

public Node importNode(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.

isId

public abstract boolean isId(Attr node)
Returns whether the given attribute node is an ID attribute.

nodeToBeRemoved

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

normalizeDocument

public void normalizeDocument()
DOM: Implements {@link org.w3c.dom.Document#normalizeDocument()}. XXX Does not handle the 'entities' parameter yet.

normalizeDocument

protected boolean normalizeDocument(Element e, boolean cdataSections, boolean comments, boolean elementContentWhitepace, boolean namespaceDeclarations, boolean namespaces, boolean splitCdataSections, DOMErrorHandler errorHandler)
Helper function for {@link #normalizeDocument()}.

putElementsByTagName

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

putElementsByTagNameNS

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

removeIdEntry

public void removeIdEntry(Element e, String id)
Remove the mapping for element to id

renameNode

public Node renameNode(Node n, String ns, String qn)
DOM: Implements {@link org.w3c.dom.Document#renameNode(Node,String,String)}.

setDoctype

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

setDocumentInputEncoding

public void setDocumentInputEncoding(String ie)
Sets the input encoding that was used when the document was being parsed.

setDocumentURI

public void setDocumentURI(String uri)
DOM: Implements {@link org.w3c.dom.Document#setDocumentURI(String)}.

setDocumentXmlEncoding

public void setDocumentXmlEncoding(String xe)
Sets the XML encoding that was found in the XML prolog.

setEventsEnabled

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

setLocale

public void setLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.

setStrictErrorChecking

public void setStrictErrorChecking(boolean b)
DOM: Implements {@link org.w3c.dom.Document#setStrictErrorChecking(boolean)}.

setTextContent

public void setTextContent(String s)
DOM: Implements {@link org.w3c.dom.Node#setTextContent(String)}.

setXBLManager

public void setXBLManager(XBLManager m)
Sets the XBLManager used for this document.

setXmlStandalone

public void setXmlStandalone(boolean b)
DOM: Implements {@link org.w3c.dom.Document#setXmlStandalone(boolean)}.

setXmlVersion

public void setXmlVersion(String v)
DOM: Implements {@link org.w3c.dom.Document#setXmlVersion(String)}.

splitCdata

protected boolean splitCdata(Element e, Node n, DOMErrorHandler errorHandler)
Splits the given CDATA node if required.

updateIdEntry

public void updateIdEntry(Element e, String oldId, String newId)
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.