Class DocumentTypeImpl
- All Implemented Interfaces:
Cloneable
,DocumentType
,EventTarget
,Node
,NodeList
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 Summary
FieldsModifier and TypeFieldDescriptionprivate int
private NamedNodeMapImpl
Elements.private NamedNodeMapImpl
Entities.private String
private final String
Document type name.private NamedNodeMapImpl
Notations.private String
private String
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocument
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.ChildNode
nextSibling_, previousSibling_
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.NodeImpl
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, FIRSTCHILD, HASSTRING, ID, NORMALIZED, OWNED, ownerNode_, READONLY, SPECIFIED, SYNCCHILDREN
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
ConstructorsConstructorDescriptionDocumentTypeImpl
(CoreDocumentImpl ownerDocument, String name) Factory method for creating a document type node.DocumentTypeImpl
(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID) -
Method Summary
Modifier and TypeMethodDescriptioncloneNode
(boolean deep) Returns a duplicate of a given node.Access the collection of general Entities, both external and internal, defined in the DTD.Introduced in DOM Level 2.getName()
Name of this document type.the name of this node.protected int
NON-DOM Get the number associated with this doctype.short
A short integer indicating what type of node this is.Access the collection of Notations defined in the DTD.Introduced in DOM Level 2.Introduced in DOM Level 2.This attribute returns the text content of this node and its descendants.getUserData
(String key) Retrieves the object associated to a key on a this node.boolean
isEqualNode
(Node arg) Tests whether two nodes are equal.void
setInternalSubset
(String internalSubset) protected void
NON-DOM set the ownerDocument of this node and its childrenvoid
setTextContent
(String textContent) This attribute returns the text content of this node and its descendants.setUserData
(String key, Object data, UserDataHandler handler) Associate an object to a key on this node.Methods inherited from class org.htmlunit.cyberneko.xerces.dom.ParentNode
checkNormalizationAfterInsert, checkNormalizationAfterRemove, getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, getOwnerDocument, getTextContent, hasChildNodes, hasTextContent, insertBefore, internalInsertBefore, internalRemoveChild, item, lastChild, nodeListGetLength, nodeListItem, ownerDocument, removeChild, replaceChild, synchronizeChildren
Methods inherited from class org.htmlunit.cyberneko.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling, parentNode, previousSibling
Methods inherited from class org.htmlunit.cyberneko.xerces.dom.NodeImpl
addEventListener, appendChild, changed, changes, compareDocumentPosition, dispatchEvent, getAttributes, getBaseURI, getElementAncestor, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, hasAttributes, hasStringValue, hasStringValue, isDefaultNamespace, isFirstChild, isFirstChild, isIdAttribute, isIdAttribute, isNormalized, isNormalized, isOwned, isOwned, isSameNode, isSpecified, isSpecified, isSupported, lookupNamespacePrefix, lookupNamespaceURI, lookupPrefix, needsSyncChildren, needsSyncChildren, normalize, removeEventListener, setNodeValue, setPrefix, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, 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
-
Field Details
-
name_
Document type name. -
entities_
Entities. -
notations_
Notations. -
elements_
Elements. -
publicID_
-
systemID_
-
internalSubset_
-
doctypeNumber_
private int doctypeNumber_
-
-
Constructor Details
-
DocumentTypeImpl
Factory method for creating a document type node.- Parameters:
ownerDocument
- the owner documentname
- the name
-
DocumentTypeImpl
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID)
-
-
Method Details
-
getPublicId
Introduced in DOM Level 2.Return the public identifier of this Document type.
- Specified by:
getPublicId
in interfaceDocumentType
-
getSystemId
Introduced in DOM Level 2.Return the system identifier of this Document type.
- Specified by:
getSystemId
in interfaceDocumentType
-
setInternalSubset
-
getInternalSubset
Introduced in DOM Level 2.Return the internalSubset given as a string.
- Specified by:
getInternalSubset
in interfaceDocumentType
-
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 interfaceNode
- Specified by:
getNodeType
in classNodeImpl
-
getNodeName
the name of this node.- Specified by:
getNodeName
in interfaceNode
- Specified by:
getNodeName
in classNodeImpl
-
cloneNode
Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
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. Clones the node.
- Specified by:
cloneNode
in interfaceNode
- Overrides:
cloneNode
in classParentNode
- See Also:
-
getTextContent
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 singleText
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 nodesATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
getTextContent
in interfaceNode
- Overrides:
getTextContent
in classParentNode
- Throws:
DOMException
- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMString
variable on the implementation platform.
-
setTextContent
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 singleText
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 nodesATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
setTextContent
in interfaceNode
- Overrides:
setTextContent
in classParentNode
- Throws:
DOMException
- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMString
variable on the implementation platform.
-
isEqualNode
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 withNode.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 bothnull
, or they have the same length and are character for character identical. Theattributes
NamedNodeMaps
are equal. This is: they are bothnull
, 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.ThechildNodes
NodeLists
are equal. This is: they are bothnull
, or they have the same length and contain equal nodes at the same index. This is true forAttr
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 twoDocumentType
nodes to be equal, the following conditions must also be satisfied: The following string attributes are equal:publicId
,systemId
,internalSubset
.Theentities
NamedNodeMaps
are equal.Thenotations
NamedNodeMaps
are equal.
On the other hand, the following do not affect equality: theownerDocument
attribute, thespecified
attribute forAttr
nodes, theisWhitespaceInElementContent
attribute forText
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 interfaceNode
- Overrides:
isEqualNode
in classParentNode
- Parameters:
arg
- The node to compare equality with.- Returns:
- If the nodes, and possibly subtrees are equal,
true
otherwisefalse
.
-
setOwnerDocument
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 classParentNode
-
getNodeNumber
protected int getNodeNumber()NON-DOM Get the number associated with this doctype.- Overrides:
getNodeNumber
in classNodeImpl
- Returns:
- the node number
-
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 interfaceDocumentType
-
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 interfaceDocumentType
-
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 interfaceDocumentType
-
getElements
-
setUserData
Associate an object to a key on this node. The object can later be retrieved from this node by callinggetUserData
with the same key.- Specified by:
setUserData
in interfaceNode
- Overrides:
setUserData
in classNodeImpl
- Parameters:
key
- The key to associate the object to.data
- The object to associate to the given key, ornull
to remove any existing association to that key.handler
- The handler to associate to that key, ornull
.- Returns:
- Returns the
DOMObject
previously associated to the given key on this node, ornull
if there was none.
-
getUserData
Retrieves the object associated to a key on a this node. The object must first have been set to this node by callingsetUserData
with the same key.- Specified by:
getUserData
in interfaceNode
- Overrides:
getUserData
in classNodeImpl
- Parameters:
key
- The key the object is associated to.- Returns:
- Returns the
DOMObject
associated to the given key on this node, ornull
if there was none.
-