Class AbstractDocument

  • All Implemented Interfaces:
    java.io.Serializable, NodeEventTarget, ExtendedNode, NodeXBL, XBLManagerData, Localizable, org.w3c.dom.Document, org.w3c.dom.events.DocumentEvent, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.xpath.XPathEvaluator
    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, org.w3c.dom.xpath.XPathEvaluator
    This class implements the Document interface.
    Version:
    $Id: AbstractDocument.java 1851346 2019-01-15 13:41:00Z ssteiner $
    See Also:
    Serialized Form
    • 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.
      • inputEncoding

        protected java.lang.String inputEncoding
        Input encoding of this document.
      • xmlEncoding

        protected java.lang.String xmlEncoding
        XML encoding of this document.
      • xmlVersion

        protected java.lang.String xmlVersion
        XML version of this document.
      • xmlStandalone

        protected boolean xmlStandalone
        Whether this document is standalone.
      • documentURI

        protected java.lang.String documentURI
        The document URI.
      • strictErrorChecking

        protected boolean strictErrorChecking
        Whether strict error checking is in force.
      • xblManager

        protected transient XBLManager xblManager
        The XBL manager for this document.
      • 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

      • setDocumentInputEncoding

        public void setDocumentInputEncoding​(java.lang.String ie)
        Sets the input encoding that was used when the document was being parsed.
      • setDocumentXmlEncoding

        public void setDocumentXmlEncoding​(java.lang.String xe)
        Sets the XML encoding that was found in the XML prolog.
      • formatMessage

        public java.lang.String formatMessage​(java.lang.String key,
                                              java.lang.Object[] args)
                                       throws java.util.MissingResourceException
        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 into this document. It does so deeply if deep is set to true. It will not mark ID attributes as IDs if trimId is set to true. This is used primarily for the shadow trees of the 'use' elements so they don't clutter the hash table.
        Parameters:
        importedNode - The node to import into this document.
        deep - Whether to perform a deep importation.
        trimId - Whether to make all cloned attributes not be ID attributes.
      • 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)
        Returns whether the given attribute node is an ID attribute.
      • 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
      • canDispatch

        public boolean canDispatch​(java.lang.String ns,
                                   java.lang.String eventType)
        DOM: Implements org.w3c.dom.events.DocumentEvent#canDispatch(String,String).
      • 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
      • 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
      • getInputEncoding

        public java.lang.String getInputEncoding()
        DOM: Implements Document.getInputEncoding().
        Specified by:
        getInputEncoding in interface org.w3c.dom.Document
      • getXmlEncoding

        public java.lang.String getXmlEncoding()
        DOM: Implements Document.getXmlEncoding().
        Specified by:
        getXmlEncoding in interface org.w3c.dom.Document
      • getXmlStandalone

        public boolean getXmlStandalone()
        DOM: Implements Document.getXmlStandalone().
        Specified by:
        getXmlStandalone in interface org.w3c.dom.Document
      • setXmlStandalone

        public void setXmlStandalone​(boolean b)
                              throws org.w3c.dom.DOMException
        DOM: Implements Document.setXmlStandalone(boolean).
        Specified by:
        setXmlStandalone in interface org.w3c.dom.Document
        Throws:
        org.w3c.dom.DOMException
      • getXmlVersion

        public java.lang.String getXmlVersion()
        DOM: Implements Document.getXmlVersion().
        Specified by:
        getXmlVersion in interface org.w3c.dom.Document
      • setXmlVersion

        public void setXmlVersion​(java.lang.String v)
                           throws org.w3c.dom.DOMException
        DOM: Implements Document.setXmlVersion(String).
        Specified by:
        setXmlVersion in interface org.w3c.dom.Document
        Throws:
        org.w3c.dom.DOMException
      • getStrictErrorChecking

        public boolean getStrictErrorChecking()
        DOM: Implements Document.getStrictErrorChecking().
        Specified by:
        getStrictErrorChecking in interface org.w3c.dom.Document
      • setStrictErrorChecking

        public void setStrictErrorChecking​(boolean b)
        DOM: Implements Document.setStrictErrorChecking(boolean).
        Specified by:
        setStrictErrorChecking in interface org.w3c.dom.Document
      • getDocumentURI

        public java.lang.String getDocumentURI()
        DOM: Implements Document.getDocumentURI().
        Specified by:
        getDocumentURI in interface org.w3c.dom.Document
      • setDocumentURI

        public void setDocumentURI​(java.lang.String uri)
        DOM: Implements Document.setDocumentURI(String).
        Specified by:
        setDocumentURI in interface org.w3c.dom.Document
      • getDomConfig

        public org.w3c.dom.DOMConfiguration getDomConfig()
        DOM: Implements Document.getDomConfig().
        Specified by:
        getDomConfig in interface org.w3c.dom.Document
      • adoptNode

        public org.w3c.dom.Node adoptNode​(org.w3c.dom.Node n)
                                   throws org.w3c.dom.DOMException
        DOM: Implements Document.adoptNode(Node).
        Specified by:
        adoptNode in interface org.w3c.dom.Document
        Throws:
        org.w3c.dom.DOMException
      • renameNode

        public org.w3c.dom.Node renameNode​(org.w3c.dom.Node n,
                                           java.lang.String ns,
                                           java.lang.String qn)
        DOM: Implements Document.renameNode(Node,String,String).
        Specified by:
        renameNode in interface org.w3c.dom.Document
      • normalizeDocument

        public void normalizeDocument()
        DOM: Implements Document.normalizeDocument(). XXX Does not handle the 'entities' parameter yet.
        Specified by:
        normalizeDocument in interface org.w3c.dom.Document
      • normalizeDocument

        protected boolean normalizeDocument​(org.w3c.dom.Element e,
                                            boolean cdataSections,
                                            boolean comments,
                                            boolean elementContentWhitepace,
                                            boolean namespaceDeclarations,
                                            boolean namespaces,
                                            boolean splitCdataSections,
                                            org.w3c.dom.DOMErrorHandler errorHandler)
        Helper function for normalizeDocument().
      • splitCdata

        protected boolean splitCdata​(org.w3c.dom.Element e,
                                     org.w3c.dom.Node n,
                                     org.w3c.dom.DOMErrorHandler errorHandler)
        Splits the given CDATA node if required.
      • checkChars

        protected boolean checkChars​(java.lang.String s)
        Checks that the characters in the given string are all valid content characters.
      • checkName

        protected boolean checkName​(java.lang.String s)
        Checks that the given string is a valid XML name.
      • createDOMError

        protected org.w3c.dom.DOMError createDOMError​(java.lang.String type,
                                                      short severity,
                                                      java.lang.String key,
                                                      java.lang.Object[] args,
                                                      org.w3c.dom.Node related,
                                                      java.lang.Exception e)
        Creates a DOMError object with the given parameters.
      • setTextContent

        public void setTextContent​(java.lang.String s)
                            throws org.w3c.dom.DOMException
        DOM: Implements Node.setTextContent(String).
        Specified by:
        setTextContent in interface org.w3c.dom.Node
        Overrides:
        setTextContent in class AbstractNode
        Throws:
        org.w3c.dom.DOMException
      • setXBLManager

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

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

        public org.w3c.dom.xpath.XPathExpression createExpression​(java.lang.String expression,
                                                                  org.w3c.dom.xpath.XPathNSResolver resolver)
                                                           throws org.w3c.dom.DOMException,
                                                                  org.w3c.dom.xpath.XPathException
        DOM: Implements XPathEvaluator.createExpression(String,XPathNSResolver).
        Specified by:
        createExpression in interface org.w3c.dom.xpath.XPathEvaluator
        Throws:
        org.w3c.dom.DOMException
        org.w3c.dom.xpath.XPathException
      • createNSResolver

        public org.w3c.dom.xpath.XPathNSResolver createNSResolver​(org.w3c.dom.Node n)
        DOM: Implements XPathEvaluator.createNSResolver(Node).
        Specified by:
        createNSResolver in interface org.w3c.dom.xpath.XPathEvaluator
      • evaluate

        public java.lang.Object evaluate​(java.lang.String expression,
                                         org.w3c.dom.Node contextNode,
                                         org.w3c.dom.xpath.XPathNSResolver resolver,
                                         short type,
                                         java.lang.Object result)
                                  throws org.w3c.dom.xpath.XPathException,
                                         org.w3c.dom.DOMException
        DOM: Implements XPathEvaluator.evaluate(String,Node,XPathNSResolver,short,Object).
        Specified by:
        evaluate in interface org.w3c.dom.xpath.XPathEvaluator
        Throws:
        org.w3c.dom.xpath.XPathException
        org.w3c.dom.DOMException
      • createXPathException

        public org.w3c.dom.xpath.XPathException createXPathException​(short type,
                                                                     java.lang.String key,
                                                                     java.lang.Object[] args)
        Creates an exception with the appropriate error message.
      • getXblNextSibling

        public org.w3c.dom.Node getXblNextSibling()
        Get the node which directly follows the current node in the xblParentNode's xblChildNodes list.
        Specified by:
        getXblNextSibling in interface NodeXBL
        Overrides:
        getXblNextSibling in class AbstractNode
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream s)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readObject

        private void readObject​(java.io.ObjectInputStream s)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException