org.apache.xerces.dom
Class DocumentTypeImpl

java.lang.Object
  extended by org.apache.xerces.dom.NodeImpl
      extended by org.apache.xerces.dom.ChildNode
          extended by org.apache.xerces.dom.ParentNode
              extended by org.apache.xerces.dom.DocumentTypeImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DocumentType, EventTarget, Node, NodeList
Direct Known Subclasses:
DeferredDocumentTypeImpl

public class DocumentTypeImpl
extends ParentNode
implements 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.

Since:
PR-DOM-Level-1-19980818.
Version:
$Id: DocumentTypeImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
Author:
Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.xerces.dom.NodeImpl
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, ELEMENT_DEFINITION_NODE, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODE
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
DocumentTypeImpl(CoreDocumentImpl ownerDocument, java.lang.String name)
          Factory method for creating a document type node.
DocumentTypeImpl(CoreDocumentImpl ownerDocument, java.lang.String qualifiedName, java.lang.String publicID, java.lang.String systemID)
          Factory method for creating a document type node.
 
Method Summary
 Node cloneNode(boolean deep)
          Clones the node.
 NamedNodeMap getElements()
          NON-DOM: Access the collection of ElementDefinitions.
 NamedNodeMap getEntities()
          Access the collection of general Entities, both external and internal, defined in the DTD.
 java.lang.String getInternalSubset()
          Introduced in DOM Level 2.
 java.lang.String getName()
          Name of this document type.
 java.lang.String getNodeName()
          Returns the document type name
 short getNodeType()
          A short integer indicating what type of node this is.
 NamedNodeMap getNotations()
          Access the collection of Notations defined in the DTD.
 java.lang.String getPublicId()
          Introduced in DOM Level 2.
 java.lang.String getSystemId()
          Introduced in DOM Level 2.
 java.lang.String getTextContent()
          This attribute returns the text content of this node and its descendants.
 java.lang.Object getUserData(java.lang.String key)
          Retrieves the object associated to a key on a this node.
 boolean isEqualNode(Node arg)
          DOM Level 3 WD- Experimental.
 void setInternalSubset(java.lang.String internalSubset)
          NON-DOM.
 void setReadOnly(boolean readOnly, boolean deep)
          NON-DOM: Subclassed to flip the entities' and notations' readonly switch as well.
 void setTextContent(java.lang.String textContent)
          This attribute returns the text content of this node and its descendants.
 java.lang.Object setUserData(java.lang.String key, java.lang.Object data, UserDataHandler handler)
          Associate an object to a key on this node.
 
Methods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getFirstChild, getLastChild, getLength, getOwnerDocument, hasChildNodes, insertBefore, item, normalize, removeChild, replaceChild
 
Methods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
 
Methods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

DocumentTypeImpl

public DocumentTypeImpl(CoreDocumentImpl ownerDocument,
                        java.lang.String name)
Factory method for creating a document type node.


DocumentTypeImpl

public DocumentTypeImpl(CoreDocumentImpl ownerDocument,
                        java.lang.String qualifiedName,
                        java.lang.String publicID,
                        java.lang.String systemID)
Factory method for creating a document type node.

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 DocumentType
Since:
WD-DOM-Level-2-19990923

getSystemId

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

Return the system identifier of this Document type.

Specified by:
getSystemId in interface DocumentType
Since:
WD-DOM-Level-2-19990923

setInternalSubset

public void setInternalSubset(java.lang.String internalSubset)
NON-DOM.

Set the internalSubset given as a string.


getInternalSubset

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

Return the internalSubset given as a string.

Specified by:
getInternalSubset in interface DocumentType
Since:
WD-DOM-Level-2-19990923

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.

Specified by:
getNodeType in interface Node
Specified by:
getNodeType in class NodeImpl

getNodeName

public java.lang.String getNodeName()
Returns the document type name

Specified by:
getNodeName in interface Node
Specified by:
getNodeName in class NodeImpl

cloneNode

public Node cloneNode(boolean deep)
Clones the node.

Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class ParentNode
Parameters:
deep - If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
Returns:
The duplicate node.
See Also:

Example: Cloning a Text node will copy both the node and the text it contains.

Example: Cloning something that has children -- Element or Attr, for example -- will _not_ clone those children unless a "deep clone" has been requested. A shallow clone of an Attr node will yield an empty Attr of the same name.

NOTE: Clones will always be read/write, even if the node being cloned is read-only, to permit applications using only the DOM API to obtain editable copies of locked portions of the tree.


getTextContent

public java.lang.String getTextContent()
                                throws 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: /** 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
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 Node
Overrides:
getTextContent in class ParentNode
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

setTextContent

public void setTextContent(java.lang.String textContent)
                    throws 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 Node
Overrides:
setTextContent in class ParentNode
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

isEqualNode

public boolean isEqualNode(Node arg)
DOM Level 3 WD- Experimental. Override inherited behavior from ParentNodeImpl to support deep equal.

Specified by:
isEqualNode in interface 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.

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 DocumentType

getEntities

public 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 DocumentType

getNotations

public 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 DocumentType

setReadOnly

public void setReadOnly(boolean readOnly,
                        boolean deep)
NON-DOM: Subclassed to flip the entities' and notations' readonly switch as well.

Overrides:
setReadOnly in class ParentNode
Parameters:
readOnly - True or false as desired.
deep - If true, children are also toggled. Note that this will not change the state of an EntityReference or its children, which are always read-only.
See Also:
NodeImpl.setReadOnly(boolean, boolean)

getElements

public NamedNodeMap getElements()
NON-DOM: Access the collection of ElementDefinitions.

See Also:
ElementDefinitionImpl

setUserData

public java.lang.Object setUserData(java.lang.String key,
                                    java.lang.Object data,
                                    UserDataHandler handler)
Description copied from class: NodeImpl
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 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)
Description copied from class: NodeImpl
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 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.