Class CoreDocumentImpl

  • All Implemented Interfaces:
    java.lang.Cloneable, org.w3c.dom.Document, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.NodeList
    Direct Known Subclasses:
    DocumentImpl

    public class CoreDocumentImpl
    extends ParentNode
    implements org.w3c.dom.Document
    The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

    Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.

    The CoreDocumentImpl class only implements the DOM Core. Additional modules are supported by the more complete DocumentImpl subclass.

    • Constructor Summary

      Constructors 
      Constructor Description
      CoreDocumentImpl()
      NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
      CoreDocumentImpl​(boolean grammarAccess)
      Constructor.
      CoreDocumentImpl​(org.w3c.dom.DocumentType doctype)
      For DOM2 support.
      CoreDocumentImpl​(org.w3c.dom.DocumentType doctype, boolean grammarAccess)
      For DOM2 support.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addEventListener​(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)  
      org.w3c.dom.Node adoptNode​(org.w3c.dom.Node source)
      DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document
      protected boolean canRenameElements​(java.lang.String newNamespaceURI, java.lang.String newNodeName, ElementImpl el)  
      protected void changed()
      Denotes that this node has changed.
      protected int changes()
      Returns the number of changes to this node.
      protected void checkDOMNSErr​(java.lang.String prefix, java.lang.String namespace)  
      protected void checkNamespaceWF​(java.lang.String qname, int colon1, int colon2)  
      protected void checkQName​(java.lang.String prefix, java.lang.String local)
      Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.
      protected void clearIdentifiers()
      Remove all identifiers from the ID table
      java.lang.Object clone()
      Clone.
      org.w3c.dom.Node cloneNode​(boolean deep)
      Deep-clone a document, including fixing ownerDoc for the cloned children.
      protected void cloneNode​(CoreDocumentImpl newdoc, boolean deep)  
      protected void copyEventListeners​(NodeImpl src, NodeImpl tgt)  
      org.w3c.dom.Attr createAttribute​(java.lang.String name)
      Factory method; creates an Attribute having this Document as its OwnerDoc.
      org.w3c.dom.Attr createAttributeNS​(java.lang.String namespaceURI, java.lang.String qualifiedName)
      Introduced in DOM Level 2.
      org.w3c.dom.Attr createAttributeNS​(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String localpart)
      NON-DOM: a factory method used by the Xerces DOM parser to create an element.
      org.w3c.dom.CDATASection createCDATASection​(java.lang.String data)
      Factory method; creates a CDATASection having this Document as its OwnerDoc.
      org.w3c.dom.Comment createComment​(java.lang.String data)
      Factory method; creates a Comment having this Document as its OwnerDoc.
      org.w3c.dom.DocumentFragment createDocumentFragment()
      Factory method; creates a DocumentFragment having this Document as its OwnerDoc.
      org.w3c.dom.DocumentType createDocumentType​(java.lang.String qualifiedName, java.lang.String publicID, java.lang.String systemID)
      NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc.
      org.w3c.dom.Element createElement​(java.lang.String tagName)
      Factory method; creates an Element having this Document as its OwnerDoc.
      org.w3c.dom.Element createElementNS​(java.lang.String namespaceURI, java.lang.String qualifiedName)
      Introduced in DOM Level 2.
      org.w3c.dom.Element createElementNS​(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String localpart)
      NON-DOM: a factory method used by the Xerces DOM parser to create an element.
      org.w3c.dom.Entity createEntity​(java.lang.String name)
      NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc.
      org.w3c.dom.EntityReference createEntityReference​(java.lang.String name)
      Factory method; creates an EntityReference having this Document as its OwnerDoc.
      org.w3c.dom.ProcessingInstruction createProcessingInstruction​(java.lang.String target, java.lang.String data)
      Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.
      org.w3c.dom.Text createTextNode​(java.lang.String data)
      Factory method; creates a Text node having this Document as its OwnerDoc.
      (package private) void deletedText​(CharacterDataImpl node, int offset, int count)
      A method to be called when some text was deleted from a text node, so that live objects can be notified.
      (package private) void freeNodeListCache​(NodeListCache c)
      Puts the given NodeListCache in the free list.
      java.lang.String getBaseURI()
      Returns the absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.
      org.w3c.dom.DocumentType getDoctype()
      For XML, this provides access to the Document Type Definition.
      org.w3c.dom.Element getDocumentElement()
      Convenience method, allowing direct access to the child node which is considered the root of the actual document content.
      java.lang.String getDocumentURI()
      DOM Level 3 WD - Experimental.
      org.w3c.dom.DOMConfiguration getDomConfig()
      DOM Level 3 CR - Experimental
      org.w3c.dom.Element getElementById​(java.lang.String elementId)
      Introduced in DOM Level 2 Returns the Element whose ID is given by elementId.
      org.w3c.dom.NodeList getElementsByTagName​(java.lang.String tagname)
      Return a live collection of all descendant Elements (not just immediate children) having the specified tag name.
      org.w3c.dom.NodeList getElementsByTagNameNS​(java.lang.String namespaceURI, java.lang.String localName)
      Introduced in DOM Level 2.
      boolean getErrorChecking()  
      org.w3c.dom.Element getIdentifier​(java.lang.String idName)
      Returns a previously registered element with the specified identifier name, or null if no element is registered.
      org.w3c.dom.DOMImplementation getImplementation()
      Retrieve information describing the abilities of this particular DOM implementation.
      java.lang.String getInputEncoding()
      DOM Level 3 CR - Experimental.
      (package private) NodeListCache getNodeListCache​(ParentNode owner)
      Returns a NodeListCache for the given node.
      java.lang.String getNodeName()
      Returns the node name.
      protected int getNodeNumber()
      NON-DOM: Get the number associated with this document.
      protected int getNodeNumber​(org.w3c.dom.Node node)  
      short getNodeType()
      Returns the node type.
      org.w3c.dom.Document getOwnerDocument()
      Find the Document that this Node belongs to (the document in whose context the Node was created).
      boolean getStrictErrorChecking()  
      java.lang.String getTextContent()
      This attribute returns the text content of this node and its descendants.
      java.lang.String getXmlEncoding()
      DOM Level 3 WD - Experimental.
      boolean getXmlStandalone()
      DOM Level 3 WD - Experimental.
      java.lang.String getXmlVersion()
      DOM Level 3 WD - Experimental.
      org.w3c.dom.Node importNode​(org.w3c.dom.Node source, boolean deep)
      Copies a node from another document to this document.
      private org.w3c.dom.Node importNode​(org.w3c.dom.Node source, boolean deep, boolean cloningDoc, java.util.HashMap<org.w3c.dom.Node,​java.lang.String> reversedIdentifiers)
      Overloaded implementation of DOM's importNode method.
      org.w3c.dom.Node insertBefore​(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
      Since a Document may contain at most one top-level Element child, and at most one DocumentType declaraction, we need to subclass our add-children methods to implement this constraint.
      (package private) void insertedNode​(NodeImpl node, NodeImpl newInternal, boolean replace)
      A method to be called when a node has been inserted in the tree.
      (package private) void insertedText​(CharacterDataImpl node, int offset, int count)
      A method to be called when some text was inserted into a text node, so that live objects can be notified.
      (package private) void insertingNode​(NodeImpl node, boolean replace)
      A method to be called when a node is about to be inserted in the tree.
      protected boolean isKidOK​(org.w3c.dom.Node parent, org.w3c.dom.Node child)
      Uses the kidOK lookup table to check whether the proposed tree structure is legal.
      static boolean isValidQName​(java.lang.String prefix, java.lang.String local, boolean xml11Version)
      Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.
      (package private) boolean isXML11Version()
      We could have more xml versions in future , but for now we could do with this to handle XML 1.0 and 1.1
      static boolean isXMLName​(java.lang.String s, boolean xml11Version)
      Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class
      (package private) void modifiedAttrValue​(AttrImpl attr, java.lang.String oldvalue)
      A method to be called when an attribute value has been modified
      (package private) void modifiedCharacterData​(NodeImpl node, java.lang.String oldvalue, java.lang.String value, boolean replace)
      A method to be called when a character data node has been modified
      (package private) void modifyingCharacterData​(NodeImpl node, boolean replace)
      A method to be called when a character data node is about to be modified
      void normalizeDocument()
      DOM Level 3 WD - Experimental Normalize document.
      void putIdentifier​(java.lang.String idName, org.w3c.dom.Element element)
      Registers an identifier name with a specified element node.
      org.w3c.dom.Node removeChild​(org.w3c.dom.Node oldChild)
      Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cache
      (package private) void removedAttrNode​(AttrImpl attr, NodeImpl oldOwner, java.lang.String name)
      A method to be called when an attribute node has been removed
      (package private) void removedNode​(NodeImpl node, boolean replace)
      A method to be called when a node has been removed from the tree.
      protected void removeEventListener​(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)  
      void removeIdentifier​(java.lang.String idName)
      Removes a previously registered element with the specified identifier name.
      (package private) void removingNode​(NodeImpl node, NodeImpl oldChild, boolean replace)
      A method to be called when a node is about to be removed from the tree.
      (package private) void renamedAttrNode​(org.w3c.dom.Attr oldAt, org.w3c.dom.Attr newAt)
      A method to be called when an attribute node has been renamed
      (package private) void renamedElement​(org.w3c.dom.Element oldEl, org.w3c.dom.Element newEl)
      A method to be called when an element has been renamed
      org.w3c.dom.Node renameNode​(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String name)
      DOM Level 3 WD - Experimental.
      org.w3c.dom.Node replaceChild​(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
      Since we cache the docElement (and, currently, docType), replaceChild has to update the cache
      (package private) void replacedCharacterData​(NodeImpl node, java.lang.String oldvalue, java.lang.String value)
      method to be called when a character data node has been replaced.
      (package private) void replacedNode​(NodeImpl node)
      A method to be called when a node has been replaced in the tree.
      (package private) void replacedText​(CharacterDataImpl node)
      A method to be called when some text was changed in a text node, so that live objects can be notified.
      private ElementImpl replaceRenameElement​(ElementImpl el, java.lang.String namespaceURI, java.lang.String name)  
      (package private) void replacingData​(NodeImpl node)
      A method to be called when a character data node is about to be replaced
      (package private) void replacingNode​(NodeImpl node)
      A method to be called when a node is about to be replaced in the tree.
      (package private) void setAttrNode​(AttrImpl attr, AttrImpl previous)
      A method to be called when an attribute node has been set
      void setDocumentURI​(java.lang.String documentURI)
      DOM Level 3 WD - Experimental.
      void setErrorChecking​(boolean check)
      Sets whether the DOM implementation performs error checking upon operations.
      void setInputEncoding​(java.lang.String value)
      DOM Internal (Was a DOM L3 Core WD public interface method setActualEncoding )
      void setStrictErrorChecking​(boolean check)  
      void setTextContent​(java.lang.String textContent)
      This attribute returns the text content of this node and its descendants.
      void setXmlEncoding​(java.lang.String value)
      DOM Internal (Was a DOM L3 Core WD public interface method setXMLEncoding )
      void setXmlStandalone​(boolean value)
      DOM Level 3 CR - Experimental.
      void setXmlVersion​(java.lang.String value)
      DOM Level 3 CR - Experimental.
      protected void undeferChildren​(org.w3c.dom.Node node)
      Traverses the DOM Tree and expands deferred nodes and their children.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.w3c.dom.Node

        appendChild, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setUserData
    • Field Detail

      • docElement_

        private ElementImpl docElement_
        Document element.
      • fFreeNLCache_

        private NodeListCache fFreeNLCache_
        NodeListCache free list
      • encoding_

        private java.lang.String encoding_
        Experimental DOM Level 3 feature: Document encoding
      • actualEncoding_

        private java.lang.String actualEncoding_
        Experimental DOM Level 3 feature: Document actualEncoding
      • version_

        private java.lang.String version_
        Experimental DOM Level 3 feature: Document version
      • standalone_

        private boolean standalone_
        Experimental DOM Level 3 feature: Document standalone
      • fDocumentURI_

        private java.lang.String fDocumentURI_
        Experimental DOM Level 3 feature: documentURI
      • identifiers_

        private java.util.HashMap<java.lang.String,​org.w3c.dom.Element> identifiers_
        Identifiers.
      • kidOK

        private static final int[] kidOK
        Table for quick check of child insertion.
      • changes

        protected int changes
        Number of alterations made to this document since its creation. Serves as a "dirty bit" so that live objects such as NodeList can recognize when an alteration has been made and discard its cached state information.

        Any method that alters the tree structure MUST cause or be accompanied by a call to changed(), to inform it that any outstanding NodeLists may have to be updated.

        (Required because NodeList is simultaneously "live" and integer- indexed -- a bad decision in the DOM's design.)

        Note that changes which do not affect the tree's structure -- changing the node's name, for example -- do _not_ have to call changed().

        Alternative implementation would be to use a cryptographic Digest value rather than a count. This would have the advantage that "harmless" changes (those producing equal() trees) would not force NodeList to resynchronize. Disadvantage is that it's slightly more prone to "false negatives", though that's the difference between "wildly unlikely" and "absurdly unlikely". IF we start maintaining digests, we should consider taking advantage of them.

        Note: This used to be done a node basis, so that we knew what subtree changed. But since only DeepNodeList really use this today, the gain appears to be really small compared to the cost of having an int on every (parent) node plus having to walk up the tree all the way to the root to mark the branch as changed everytime a node is changed. So we now have a single counter global to the document. It means that some objects may flush their cache more often than necessary, but this makes nodes smaller and only the document needs to be marked as changed.

      • allowGrammarAccess

        protected boolean allowGrammarAccess
        Allow grammar access.
      • errorChecking

        protected boolean errorChecking
        Bypass error checking.
      • documentNumber_

        private int documentNumber_
        The following are required for compareDocumentPosition
      • nodeCounter_

        private int nodeCounter_
      • nodeTable_

        private java.util.Map<org.w3c.dom.Node,​java.lang.Integer> nodeTable_
      • xml11Version_

        private boolean xml11Version_
    • Constructor Detail

      • CoreDocumentImpl

        public CoreDocumentImpl()
        NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
      • CoreDocumentImpl

        public CoreDocumentImpl​(boolean grammarAccess)
        Constructor.
        Parameters:
        grammarAccess - grammar acess flag
      • CoreDocumentImpl

        public CoreDocumentImpl​(org.w3c.dom.DocumentType doctype)
        For DOM2 support. The createDocument factory method is in DOMImplementation.
        Parameters:
        doctype - the DocumentType
      • CoreDocumentImpl

        public CoreDocumentImpl​(org.w3c.dom.DocumentType doctype,
                                boolean grammarAccess)
        For DOM2 support.
        Parameters:
        doctype - the DocumentType
        grammarAccess - grammar access flag
    • Method Detail

      • getOwnerDocument

        public final org.w3c.dom.Document getOwnerDocument()
        Description copied from class: ParentNode
        Find the Document that this Node belongs to (the document in whose context the Node was created). The Node may or may not currently be part of that Document's actual contents. Find the Document that this Node belongs to (the document in whose context the Node was created). The Node may or may not currently be part of that Document's actual contents.
        Specified by:
        getOwnerDocument in interface org.w3c.dom.Node
        Overrides:
        getOwnerDocument in class ParentNode
      • getNodeType

        public short getNodeType()
        Returns the node type.
        Specified by:
        getNodeType in interface org.w3c.dom.Node
        Specified by:
        getNodeType in class NodeImpl
      • getNodeName

        public java.lang.String getNodeName()
        Returns the node name.
        Specified by:
        getNodeName in interface org.w3c.dom.Node
        Specified by:
        getNodeName in class NodeImpl
      • cloneNode

        protected void cloneNode​(CoreDocumentImpl newdoc,
                                 boolean deep)
      • insertBefore

        public org.w3c.dom.Node insertBefore​(org.w3c.dom.Node newChild,
                                             org.w3c.dom.Node refChild)
                                      throws org.w3c.dom.DOMException
        Since a Document may contain at most one top-level Element child, and at most one DocumentType declaraction, we need to subclass our add-children methods to implement this constraint. Since appendChild() is implemented as insertBefore(,null), altering the latter fixes both.

        While I'm doing so, I've taken advantage of the opportunity to cache documentElement and docType so we don't have to search for them.

        REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way

        Specified by:
        insertBefore in interface org.w3c.dom.Node
        Overrides:
        insertBefore in class ParentNode
        Parameters:
        newChild - The Node to be moved to our subtree. As a convenience feature, inserting a DocumentNode will instead insert all its children.
        refChild - Current child which newChild should be placed immediately before. If refChild is null, the insertion occurs after all existing Nodes, like appendChild().
        Returns:
        newChild, in its new state (relocated, or emptied in the case of DocumentNode.)
        Throws:
        org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR if newChild is of a type that shouldn't be a child of this node, or if newChild is an ancestor of this node.
        See Also:
        ParentNode
      • removeChild

        public org.w3c.dom.Node removeChild​(org.w3c.dom.Node oldChild)
                                     throws org.w3c.dom.DOMException
        Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cache

        REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way

        Specified by:
        removeChild in interface org.w3c.dom.Node
        Overrides:
        removeChild in class ParentNode
        Returns:
        oldChild, in its new state (removed).
        Throws:
        org.w3c.dom.DOMException - NOT_FOUND_ERR if oldChild is not a child of this node.
        See Also:
        ParentNode
      • replaceChild

        public org.w3c.dom.Node replaceChild​(org.w3c.dom.Node newChild,
                                             org.w3c.dom.Node oldChild)
                                      throws org.w3c.dom.DOMException
        Since we cache the docElement (and, currently, docType), replaceChild has to update the cache

        REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way

        Specified by:
        replaceChild in interface org.w3c.dom.Node
        Overrides:
        replaceChild in class ParentNode
        Returns:
        oldChild, in its new state (removed).
        Throws:
        org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR if newChild is of a type that shouldn't be a child of this node, or if newChild is one of our ancestors.
        See Also:
        ParentNode
      • getTextContent

        public java.lang.String getTextContent()
                                        throws org.w3c.dom.DOMException
        Description copied from class: NodeImpl
        This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. When set, any possible children this node may have are removed and replaced by a single Text node containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed, the returned string does not contain the element content whitespaces . Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
        The string returned is made of the text content of this node depending on its type, as defined below:
        Node type Content
        ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes
        ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
        DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null
        Specified by:
        getTextContent in interface org.w3c.dom.Node
        Overrides:
        getTextContent in class ParentNode
        Throws:
        org.w3c.dom.DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.
      • setTextContent

        public void setTextContent​(java.lang.String textContent)
                            throws org.w3c.dom.DOMException
        Description copied from class: NodeImpl
        This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. When set, any possible children this node may have are removed and replaced by a single Text node containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed, the returned string does not contain the element content whitespaces . Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
        The string returned is made of the text content of this node depending on its type, as defined below:
        Node type Content
        ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes
        ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
        DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null
        Specified by:
        setTextContent in interface org.w3c.dom.Node
        Overrides:
        setTextContent in class ParentNode
        Throws:
        org.w3c.dom.DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.
      • createAttribute

        public org.w3c.dom.Attr createAttribute​(java.lang.String name)
                                         throws org.w3c.dom.DOMException
        Factory method; creates an Attribute having this Document as its OwnerDoc.
        Specified by:
        createAttribute in interface org.w3c.dom.Document
        Parameters:
        name - The name of the attribute. Note that the attribute's value is _not_ established at the factory; remember to set it!
        Throws:
        org.w3c.dom.DOMException - INVALID_NAME_ERR if the attribute name is not acceptable.
      • createCDATASection

        public org.w3c.dom.CDATASection createCDATASection​(java.lang.String data)
                                                    throws org.w3c.dom.DOMException
        Factory method; creates a CDATASection having this Document as its OwnerDoc.
        Specified by:
        createCDATASection in interface org.w3c.dom.Document
        Parameters:
        data - The initial contents of the CDATA
        Throws:
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR for HTML documents. (HTML not yet implemented.)
      • createComment

        public org.w3c.dom.Comment createComment​(java.lang.String data)
        Factory method; creates a Comment having this Document as its OwnerDoc.
        Specified by:
        createComment in interface org.w3c.dom.Document
        Parameters:
        data - The initial contents of the Comment.
        Returns:
        comment
      • createDocumentFragment

        public org.w3c.dom.DocumentFragment createDocumentFragment()
        Factory method; creates a DocumentFragment having this Document as its OwnerDoc.
        Specified by:
        createDocumentFragment in interface org.w3c.dom.Document
      • createElement

        public org.w3c.dom.Element createElement​(java.lang.String tagName)
                                          throws org.w3c.dom.DOMException
        Factory method; creates an Element having this Document as its OwnerDoc.
        Specified by:
        createElement in interface org.w3c.dom.Document
        Parameters:
        tagName - The 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.
        Throws:
        org.w3c.dom.DOMException - INVALID_NAME_ERR if the tag name is not acceptable.
      • createEntityReference

        public org.w3c.dom.EntityReference createEntityReference​(java.lang.String name)
                                                          throws org.w3c.dom.DOMException
        Factory method; creates an EntityReference having this Document as its OwnerDoc.
        Specified by:
        createEntityReference in interface org.w3c.dom.Document
        Parameters:
        name - The name of the Entity we wish to refer to
        Throws:
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)
      • createProcessingInstruction

        public org.w3c.dom.ProcessingInstruction createProcessingInstruction​(java.lang.String target,
                                                                             java.lang.String data)
                                                                      throws org.w3c.dom.DOMException
        Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.
        Specified by:
        createProcessingInstruction in interface org.w3c.dom.Document
        Parameters:
        target - The target "processor channel"
        data - Parameter string to be passed to the target.
        Throws:
        org.w3c.dom.DOMException - INVALID_NAME_ERR if the target name is not acceptable.
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR for HTML documents. (HTML not yet implemented.)
      • createTextNode

        public org.w3c.dom.Text createTextNode​(java.lang.String data)
        Factory method; creates a Text node having this Document as its OwnerDoc.
        Specified by:
        createTextNode in interface org.w3c.dom.Document
        Parameters:
        data - The initial contents of the Text.
        Returns:
        the text
      • getDoctype

        public org.w3c.dom.DocumentType getDoctype()
        For XML, this provides access to the Document Type Definition. For HTML documents, and XML documents which don't specify a DTD, it will be null.
        Specified by:
        getDoctype in interface org.w3c.dom.Document
      • getDocumentElement

        public org.w3c.dom.Element getDocumentElement()
        Convenience method, allowing direct access to the child node which is considered the root of the actual document content. For HTML, where it is legal to have more than one Element at the top level of the document, we pick the one with the tagName "HTML". For XML there should be only one top-level

        (HTML not yet supported.)

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

        public org.w3c.dom.NodeList getElementsByTagName​(java.lang.String tagname)
        Return a live collection of all descendant Elements (not just immediate children) having the specified tag name.
        Specified by:
        getElementsByTagName in interface org.w3c.dom.Document
        Parameters:
        tagname - The type of Element we want to gather. "*" will be taken as a wildcard, meaning "all elements in the document."
        See Also:
        DeepNodeListImpl
      • getImplementation

        public org.w3c.dom.DOMImplementation getImplementation()
        Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.
        Specified by:
        getImplementation in interface org.w3c.dom.Document
      • setErrorChecking

        public void setErrorChecking​(boolean check)
        Sets whether the DOM implementation performs error checking upon operations. Turning off error checking only affects the following DOM checks:
        • Checking strings to make sure that all characters are legal XML characters
        • Hierarchy checking such as allowed children, checks for cycles, etc.

        Turning off error checking does not turn off the following checks:

        • Read only checks
        • Checks related to DOM events
        Parameters:
        check - check flag
      • setStrictErrorChecking

        public void setStrictErrorChecking​(boolean check)
        Specified by:
        setStrictErrorChecking in interface org.w3c.dom.Document
      • getErrorChecking

        public boolean getErrorChecking()
        Returns:
        true if the DOM implementation performs error checking.
      • getStrictErrorChecking

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

        public java.lang.String getInputEncoding()
        DOM Level 3 CR - Experimental. (Was getActualEncoding)

        An attribute specifying the encoding used for this document at the time of the parsing. This is null when it is not known, such as when the Document was created in memory.

        Specified by:
        getInputEncoding in interface org.w3c.dom.Document
      • setInputEncoding

        public void setInputEncoding​(java.lang.String value)
        DOM Internal (Was a DOM L3 Core WD public interface method setActualEncoding )

        An attribute specifying the actual encoding of this document. This is null otherwise.
        This attribute represents the property [character encoding scheme] defined in.

        Parameters:
        value - the value
      • setXmlEncoding

        public void setXmlEncoding​(java.lang.String value)
        DOM Internal (Was a DOM L3 Core WD public interface method setXMLEncoding )

        An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

        Parameters:
        value - the value
      • getXmlEncoding

        public java.lang.String getXmlEncoding()
        DOM Level 3 WD - Experimental. The encoding of this document (part of XML Declaration)
        Specified by:
        getXmlEncoding in interface org.w3c.dom.Document
      • setXmlVersion

        public void setXmlVersion​(java.lang.String value)
        DOM Level 3 CR - Experimental. version - An attribute specifying, as part of the XML declaration, the version number of this document.
        Specified by:
        setXmlVersion in interface org.w3c.dom.Document
      • getXmlVersion

        public java.lang.String getXmlVersion()
        DOM Level 3 WD - Experimental. The version of this document (part of XML Declaration)
        Specified by:
        getXmlVersion in interface org.w3c.dom.Document
      • setXmlStandalone

        public void setXmlStandalone​(boolean value)
                              throws org.w3c.dom.DOMException
        DOM Level 3 CR - Experimental.

        Xmlstandalone - An attribute specifying, as part of the XML declaration, whether this document is standalone

        Specified by:
        setXmlStandalone in interface org.w3c.dom.Document
        Throws:
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.
      • getXmlStandalone

        public boolean getXmlStandalone()
        DOM Level 3 WD - Experimental. standalone that specifies whether this document is standalone (part of XML Declaration)
        Specified by:
        getXmlStandalone in interface org.w3c.dom.Document
      • getDocumentURI

        public java.lang.String getDocumentURI()
        DOM Level 3 WD - Experimental. The location of the document or null if undefined.
        Beware that when the Document supports the feature "HTML" , the href attribute of the HTML BASE element takes precedence over this attribute.
        Specified by:
        getDocumentURI in interface org.w3c.dom.Document
      • canRenameElements

        protected boolean canRenameElements​(java.lang.String newNamespaceURI,
                                            java.lang.String newNodeName,
                                            ElementImpl el)
      • renameNode

        public org.w3c.dom.Node renameNode​(org.w3c.dom.Node n,
                                           java.lang.String namespaceURI,
                                           java.lang.String name)
                                    throws org.w3c.dom.DOMException
        DOM Level 3 WD - Experimental. Renaming node
        Specified by:
        renameNode in interface org.w3c.dom.Document
        Throws:
        org.w3c.dom.DOMException
      • replaceRenameElement

        private ElementImpl replaceRenameElement​(ElementImpl el,
                                                 java.lang.String namespaceURI,
                                                 java.lang.String name)
      • normalizeDocument

        public void normalizeDocument()
        DOM Level 3 WD - Experimental Normalize document.
        Specified by:
        normalizeDocument in interface org.w3c.dom.Document
      • getDomConfig

        public org.w3c.dom.DOMConfiguration getDomConfig()
        DOM Level 3 CR - Experimental

        The configuration used when Document.normalizeDocument is invoked.

        Specified by:
        getDomConfig in interface org.w3c.dom.Document
      • getBaseURI

        public java.lang.String getBaseURI()
        Returns the absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI. Note: If the URI is malformed, a null is returned.
        Specified by:
        getBaseURI in interface org.w3c.dom.Node
        Overrides:
        getBaseURI in class NodeImpl
        Returns:
        The absolute base URI of this node or null.
      • setDocumentURI

        public void setDocumentURI​(java.lang.String documentURI)
        DOM Level 3 WD - Experimental.
        Specified by:
        setDocumentURI in interface org.w3c.dom.Document
      • createDocumentType

        public org.w3c.dom.DocumentType createDocumentType​(java.lang.String qualifiedName,
                                                           java.lang.String publicID,
                                                           java.lang.String systemID)
                                                    throws org.w3c.dom.DOMException
        NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)
        Parameters:
        qualifiedName - the name
        publicID - the public id
        systemID - the system id
        Returns:
        the DocumentType
        Throws:
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR for HTML documents, where DTDs are not permitted. (HTML not yet implemented.)
      • createEntity

        public org.w3c.dom.Entity createEntity​(java.lang.String name)
                                        throws org.w3c.dom.DOMException
        NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)
        Parameters:
        name - The name of the Entity we wish to provide a value for.
        Returns:
        the new entity
        Throws:
        org.w3c.dom.DOMException - NOT_SUPPORTED_ERR for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)
      • getNodeNumber

        protected int getNodeNumber()
        NON-DOM: Get the number associated with this document. Used to order documents in the implementation.
        Overrides:
        getNodeNumber in class NodeImpl
        Returns:
        the node number
      • getNodeNumber

        protected int getNodeNumber​(org.w3c.dom.Node node)
      • importNode

        public org.w3c.dom.Node importNode​(org.w3c.dom.Node source,
                                           boolean deep)
                                    throws org.w3c.dom.DOMException
        Copies a node from another document to this document. The new nodes are created using this document's factory methods and are populated with the data from the source's accessor methods defined by the DOM interfaces. Its behavior is otherwise similar to that of cloneNode.

        According to the DOM specifications, document nodes cannot be imported and a NOT_SUPPORTED_ERR exception is thrown if attempted.

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

        private org.w3c.dom.Node importNode​(org.w3c.dom.Node source,
                                            boolean deep,
                                            boolean cloningDoc,
                                            java.util.HashMap<org.w3c.dom.Node,​java.lang.String> reversedIdentifiers)
                                     throws org.w3c.dom.DOMException
        Overloaded implementation of DOM's importNode method. This method provides the core functionality for the public importNode and cloneNode methods.

        The reversedIdentifiers parameter is provided for cloneNode to preserve the document's identifiers. The HashMap has Elements as the keys and their identifiers as the values. When an element is being imported, a check is done for an associated identifier. If one exists, the identifier is registered with the new, imported element. If reversedIdentifiers is null, the parameter is not applied.

        Parameters:
        source - the source node
        deep - true for deep iport
        cloningDoc - the cloning Doc
        reversedIdentifiers - helper
        Throws:
        org.w3c.dom.DOMException
      • adoptNode

        public org.w3c.dom.Node adoptNode​(org.w3c.dom.Node source)
        DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document
        Specified by:
        adoptNode in interface org.w3c.dom.Document
        Parameters:
        source - The node to adopt.
        See Also:
        importNode(org.w3c.dom.Node, boolean)
      • undeferChildren

        protected void undeferChildren​(org.w3c.dom.Node node)
        Traverses the DOM Tree and expands deferred nodes and their children.
        Parameters:
        node - the node
      • getElementById

        public org.w3c.dom.Element getElementById​(java.lang.String elementId)
        Introduced in DOM Level 2 Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.

        Note: The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.

        Specified by:
        getElementById in interface org.w3c.dom.Document
        See Also:
        getIdentifier(java.lang.String)
      • clearIdentifiers

        protected final void clearIdentifiers()
        Remove all identifiers from the ID table
      • putIdentifier

        public void putIdentifier​(java.lang.String idName,
                                  org.w3c.dom.Element element)
        Registers an identifier name with a specified element node. If the identifier is already registered, the new element node replaces the previous node. If the specified element node is null, removeIdentifier() is called.
        Parameters:
        idName - the name
        element - the element
        See Also:
        getIdentifier(String), removeIdentifier(String)
      • getIdentifier

        public org.w3c.dom.Element getIdentifier​(java.lang.String idName)
        Returns a previously registered element with the specified identifier name, or null if no element is registered.
        Parameters:
        idName - the name
        Returns:
        the element
        See Also:
        putIdentifier(String, Element), removeIdentifier(String)
      • createElementNS

        public org.w3c.dom.Element createElementNS​(java.lang.String namespaceURI,
                                                   java.lang.String qualifiedName)
                                            throws org.w3c.dom.DOMException
        Introduced in DOM Level 2.

        Creates an element of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

        Specified by:
        createElementNS in interface org.w3c.dom.Document
        Parameters:
        namespaceURI - The namespace URI of the element to create.
        qualifiedName - The qualified name of the element type to instantiate.
        Returns:
        Element A new Element object with the following attributes:
        Throws:
        org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
        org.w3c.dom.DOMException - NAMESPACE_ERR: Raised if the qualifiedName has a prefix that is "xml" and the namespaceURI is neither null nor an empty string nor "http://www.w3.org/XML/1998/namespace", or if the qualifiedName has a prefix different from "xml" and the namespaceURI is null or an empty string.
      • createElementNS

        public org.w3c.dom.Element createElementNS​(java.lang.String namespaceURI,
                                                   java.lang.String qualifiedName,
                                                   java.lang.String localpart)
                                            throws org.w3c.dom.DOMException
        NON-DOM: a factory method used by the Xerces DOM parser to create an element.
        Parameters:
        namespaceURI - The namespace URI of the element to create.
        qualifiedName - The qualified name of the element type to instantiate.
        localpart - The local name of the attribute to instantiate.
        Returns:
        Element A new Element object with the following attributes:
        Throws:
        org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
      • createAttributeNS

        public org.w3c.dom.Attr createAttributeNS​(java.lang.String namespaceURI,
                                                  java.lang.String qualifiedName)
                                           throws org.w3c.dom.DOMException
        Introduced in DOM Level 2.

        Creates an attribute of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

        Specified by:
        createAttributeNS in interface org.w3c.dom.Document
        Parameters:
        namespaceURI - The namespace URI of the attribute to create. When it is null or an empty string, this method behaves like createAttribute.
        qualifiedName - The qualified name of the attribute to instantiate.
        Returns:
        Attr A new Attr object.
        Throws:
        org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
      • createAttributeNS

        public org.w3c.dom.Attr createAttributeNS​(java.lang.String namespaceURI,
                                                  java.lang.String qualifiedName,
                                                  java.lang.String localpart)
                                           throws org.w3c.dom.DOMException
        NON-DOM: a factory method used by the Xerces DOM parser to create an element.
        Parameters:
        namespaceURI - The namespace URI of the attribute to create. When it is null or an empty string, this method behaves like createAttribute.
        qualifiedName - The qualified name of the attribute to instantiate.
        localpart - The local name of the attribute to instantiate.
        Returns:
        Attr A new Attr object.
        Throws:
        org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
      • getElementsByTagNameNS

        public org.w3c.dom.NodeList getElementsByTagNameNS​(java.lang.String namespaceURI,
                                                           java.lang.String localName)
        Introduced in DOM Level 2.

        Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the Document tree.

        Specified by:
        getElementsByTagNameNS in interface org.w3c.dom.Document
        Parameters:
        namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces. When it is null or an empty string, this method behaves like getElementsByTagName.
        localName - The local name of the elements to match on. The special value "*" matches all local names.
        Returns:
        NodeList A new NodeList object containing all the matched Elements.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clone.
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • isXMLName

        public static boolean isXMLName​(java.lang.String s,
                                        boolean xml11Version)
        Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class
        Parameters:
        s - the string to check
        xml11Version - if true use xml 11 rules
        Returns:
        true or false
      • isValidQName

        public static boolean isValidQName​(java.lang.String prefix,
                                           java.lang.String local,
                                           boolean xml11Version)
        Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.
        Parameters:
        prefix - prefix of qualified name
        local - local part of qualified name
        xml11Version - if true use xml 11 rules
        Returns:
        true or false
      • isKidOK

        protected boolean isKidOK​(org.w3c.dom.Node parent,
                                  org.w3c.dom.Node child)
        Uses the kidOK lookup table to check whether the proposed tree structure is legal.
        Parameters:
        parent - the parent
        child - the child
        Returns:
        true or false
      • changed

        protected void changed()
        Denotes that this node has changed.
        Overrides:
        changed in class NodeImpl
      • changes

        protected int changes()
        Returns the number of changes to this node.
        Overrides:
        changes in class NodeImpl
        Returns:
        the number of changes to this node.
      • getNodeListCache

        NodeListCache getNodeListCache​(ParentNode owner)
        Returns a NodeListCache for the given node.
      • freeNodeListCache

        void freeNodeListCache​(NodeListCache c)
        Puts the given NodeListCache in the free list. Note: The owner node can keep using it until we reuse it
      • checkNamespaceWF

        protected final void checkNamespaceWF​(java.lang.String qname,
                                              int colon1,
                                              int colon2)
      • checkDOMNSErr

        protected final void checkDOMNSErr​(java.lang.String prefix,
                                           java.lang.String namespace)
      • checkQName

        protected final void checkQName​(java.lang.String prefix,
                                        java.lang.String local)
        Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.
        Parameters:
        prefix - prefix of qualified name
        local - local part of qualified name
      • isXML11Version

        boolean isXML11Version()
        We could have more xml versions in future , but for now we could do with this to handle XML 1.0 and 1.1
      • addEventListener

        protected void addEventListener​(NodeImpl node,
                                        java.lang.String type,
                                        org.w3c.dom.events.EventListener listener,
                                        boolean useCapture)
      • removeEventListener

        protected void removeEventListener​(NodeImpl node,
                                           java.lang.String type,
                                           org.w3c.dom.events.EventListener listener,
                                           boolean useCapture)
      • copyEventListeners

        protected void copyEventListeners​(NodeImpl src,
                                          NodeImpl tgt)
      • replacedText

        void replacedText​(CharacterDataImpl node)
        A method to be called when some text was changed in a text node, so that live objects can be notified.
      • deletedText

        void deletedText​(CharacterDataImpl node,
                         int offset,
                         int count)
        A method to be called when some text was deleted from a text node, so that live objects can be notified.
      • insertedText

        void insertedText​(CharacterDataImpl node,
                          int offset,
                          int count)
        A method to be called when some text was inserted into a text node, so that live objects can be notified.
      • modifyingCharacterData

        void modifyingCharacterData​(NodeImpl node,
                                    boolean replace)
        A method to be called when a character data node is about to be modified
      • modifiedCharacterData

        void modifiedCharacterData​(NodeImpl node,
                                   java.lang.String oldvalue,
                                   java.lang.String value,
                                   boolean replace)
        A method to be called when a character data node has been modified
      • insertingNode

        void insertingNode​(NodeImpl node,
                           boolean replace)
        A method to be called when a node is about to be inserted in the tree.
      • insertedNode

        void insertedNode​(NodeImpl node,
                          NodeImpl newInternal,
                          boolean replace)
        A method to be called when a node has been inserted in the tree.
      • removingNode

        void removingNode​(NodeImpl node,
                          NodeImpl oldChild,
                          boolean replace)
        A method to be called when a node is about to be removed from the tree.
      • removedNode

        void removedNode​(NodeImpl node,
                         boolean replace)
        A method to be called when a node has been removed from the tree.
      • replacingNode

        void replacingNode​(NodeImpl node)
        A method to be called when a node is about to be replaced in the tree.
      • replacedNode

        void replacedNode​(NodeImpl node)
        A method to be called when a node has been replaced in the tree.
      • replacingData

        void replacingData​(NodeImpl node)
        A method to be called when a character data node is about to be replaced
      • replacedCharacterData

        void replacedCharacterData​(NodeImpl node,
                                   java.lang.String oldvalue,
                                   java.lang.String value)
        method to be called when a character data node has been replaced.
      • modifiedAttrValue

        void modifiedAttrValue​(AttrImpl attr,
                               java.lang.String oldvalue)
        A method to be called when an attribute value has been modified
      • setAttrNode

        void setAttrNode​(AttrImpl attr,
                         AttrImpl previous)
        A method to be called when an attribute node has been set
      • removedAttrNode

        void removedAttrNode​(AttrImpl attr,
                             NodeImpl oldOwner,
                             java.lang.String name)
        A method to be called when an attribute node has been removed
      • renamedAttrNode

        void renamedAttrNode​(org.w3c.dom.Attr oldAt,
                             org.w3c.dom.Attr newAt)
        A method to be called when an attribute node has been renamed
      • renamedElement

        void renamedElement​(org.w3c.dom.Element oldEl,
                            org.w3c.dom.Element newEl)
        A method to be called when an element has been renamed