Class DocumentTypeImpl

  • All Implemented Interfaces:
    java.lang.Cloneable, org.w3c.dom.DocumentType, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.NodeList

    public class DocumentTypeImpl
    extends ParentNode
    implements org.w3c.dom.DocumentType
    This class represents a Document Type declaraction in the document itself, not a Document Type Definition (DTD). An XML document may (or may not) have such a reference.

    DocumentType is an Extended DOM feature, used in XML documents but not in HTML.

    Note that Entities and Notations are no longer children of the DocumentType, but are parentless nodes hung only in their appropriate NamedNodeMaps.

    This area is UNDERSPECIFIED IN REC-DOM-Level-1-19981001 Most notably, absolutely no provision was made for storing and using Element and Attribute information. Nor was the linkage between Entities and Entity References nailed down solidly.

    • Field Detail

      • name_

        private final java.lang.String name_
        Document type name.
      • publicID_

        private java.lang.String publicID_
      • systemID_

        private java.lang.String systemID_
      • internalSubset_

        private java.lang.String internalSubset_
      • doctypeNumber_

        private int doctypeNumber_
    • Constructor Detail

      • DocumentTypeImpl

        public DocumentTypeImpl​(CoreDocumentImpl ownerDocument,
                                java.lang.String name)
        Factory method for creating a document type node.
        Parameters:
        ownerDocument - the owner document
        name - the name
      • DocumentTypeImpl

        public DocumentTypeImpl​(CoreDocumentImpl ownerDocument,
                                java.lang.String qualifiedName,
                                java.lang.String publicID,
                                java.lang.String systemID)
    • Method Detail

      • getPublicId

        public java.lang.String getPublicId()
        Introduced in DOM Level 2.

        Return the public identifier of this Document type.

        Specified by:
        getPublicId in interface org.w3c.dom.DocumentType
      • getSystemId

        public java.lang.String getSystemId()
        Introduced in DOM Level 2.

        Return the system identifier of this Document type.

        Specified by:
        getSystemId in interface org.w3c.dom.DocumentType
      • setInternalSubset

        public void setInternalSubset​(java.lang.String internalSubset)
      • getInternalSubset

        public java.lang.String getInternalSubset()
        Introduced in DOM Level 2.

        Return the internalSubset given as a string.

        Specified by:
        getInternalSubset in interface org.w3c.dom.DocumentType
      • getNodeType

        public short getNodeType()
        A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface. A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.
        Specified by:
        getNodeType in interface org.w3c.dom.Node
        Specified by:
        getNodeType in class NodeImpl
      • getNodeName

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

        public java.lang.String getTextContent()
                                        throws org.w3c.dom.DOMException
        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
        Get Node text content
        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
        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
        Set Node text content
        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.
      • isEqualNode

        public boolean isEqualNode​(org.w3c.dom.Node arg)
        Tests whether two nodes are equal.
        This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode. All nodes that are the same will also be equal, though the reverse may not be true.
        Two nodes are equal if and only if the following conditions are satisfied: The two nodes are of the same type.The following string attributes are equal: nodeName, localName, namespaceURI, prefix, nodeValue , baseURI. This is: they are both null, or they have the same length and are character for character identical. The attributes NamedNodeMaps are equal. This is: they are both null, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.The childNodes NodeLists are equal. This is: they are both null, or they have the same length and contain equal nodes at the same index. This is true for Attr nodes as for any other type of node. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.
        For two DocumentType nodes to be equal, the following conditions must also be satisfied: The following string attributes are equal: publicId, systemId, internalSubset.The entities NamedNodeMaps are equal.The notations NamedNodeMaps are equal.
        On the other hand, the following do not affect equality: the ownerDocument attribute, the specified attribute for Attr nodes, the isWhitespaceInElementContent attribute for Text nodes, as well as any user data or event listeners registered on the nodes. DOM Level 3 WD- Experimental. Override inherited behavior from NodeImpl to support deep equal. DOM Level 3 WD- Experimental. Override inherited behavior from ParentNodeImpl to support deep equal.
        Specified by:
        isEqualNode in interface org.w3c.dom.Node
        Overrides:
        isEqualNode in class ParentNode
        Parameters:
        arg - The node to compare equality with.
        Returns:
        If the nodes, and possibly subtrees are equal, true otherwise false.
      • setOwnerDocument

        protected void setOwnerDocument​(CoreDocumentImpl doc)
        NON-DOM set the ownerDocument of this node and its children NON-DOM set the ownerDocument of this node and its children
        Overrides:
        setOwnerDocument in class ParentNode
      • getNodeNumber

        protected int getNodeNumber()
        NON-DOM Get the number associated with this doctype.
        Overrides:
        getNodeNumber in class NodeImpl
        Returns:
        the node number
      • getName

        public java.lang.String getName()
        Name of this document type. If we loaded from a DTD, this should be the name immediately following the DOCTYPE keyword.
        Specified by:
        getName in interface org.w3c.dom.DocumentType
      • getEntities

        public org.w3c.dom.NamedNodeMap getEntities()
        Access the collection of general Entities, both external and internal, defined in the DTD. For example, in:
           <!doctype example SYSTEM "ex.dtd" [
             <!ENTITY foo "foo">
             <!ENTITY bar "bar">
             <!ENTITY % baz "baz">
             ]>
         

        The Entities map includes foo and bar, but not baz. It is promised that only Nodes which are Entities will exist in this NamedNodeMap.

        For HTML, this will always be null.

        Note that "built in" entities such as & and < should be converted to their actual characters before being placed in the DOM's contained text, and should be converted back when the DOM is rendered as XML or HTML, and hence DO NOT appear here.

        Specified by:
        getEntities in interface org.w3c.dom.DocumentType
      • getNotations

        public org.w3c.dom.NamedNodeMap getNotations()
        Access the collection of Notations defined in the DTD. A notation declares, by name, the format of an XML unparsed entity or is used to formally declare a Processing Instruction target.
        Specified by:
        getNotations in interface org.w3c.dom.DocumentType
      • getElements

        public org.w3c.dom.NamedNodeMap getElements()
      • setUserData

        public java.lang.Object setUserData​(java.lang.String key,
                                            java.lang.Object data,
                                            org.w3c.dom.UserDataHandler handler)
        Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key.
        Specified by:
        setUserData in interface org.w3c.dom.Node
        Overrides:
        setUserData in class NodeImpl
        Parameters:
        key - The key to associate the object to.
        data - The object to associate to the given key, or null to remove any existing association to that key.
        handler - The handler to associate to that key, or null.
        Returns:
        Returns the DOMObject previously associated to the given key on this node, or null if there was none.
      • getUserData

        public java.lang.Object getUserData​(java.lang.String key)
        Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.
        Specified by:
        getUserData in interface org.w3c.dom.Node
        Overrides:
        getUserData in class NodeImpl
        Parameters:
        key - The key the object is associated to.
        Returns:
        Returns the DOMObject associated to the given key on this node, or null if there was none.