public final class DocumentImpl extends NodeImpl implements DocumentInfo, Document
| Modifier and Type | Field and Description |
|---|---|
protected int |
sequence |
emptyArray, parentNODE_LETTERATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXTATTRIBUTE_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 and Description |
|---|
DocumentImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
Node |
adoptNode(Node source)
Attempts to adopt a node from another document to this document.
|
void |
compact(int size)
Compact the space used by this node
|
void |
copy(Outputter out)
Copy this node to a given outputter
|
void |
copyStringValue(Outputter out)
Copy the string-value of this node to a given outputter
|
void |
dropChildren()
Drop a branch of the tree.
|
AxisEnumeration |
enumerateChildren(NodeTest test)
Get an enumeration of the children of this node
|
String |
generateId()
Get a character string that uniquely identifies this node within the document
|
protected AxisEnumeration |
getAllElements(int fingerprint)
Get a list of all elements with a given name fingerprint
|
String |
getBaseURI()
Get the base URI of this root node.
|
StringBuffer |
getCharacterBuffer()
Get the character buffer
|
NodeList |
getChildNodes()
Return a
NodeList that contains all children of this node. |
Element |
getDocumentElement()
Get the root (outermost) element.
|
DocumentInfo |
getDocumentRoot()
Get the root (document) node
|
String |
getDocumentURI()
The location of the document or
null if undefined or if
the Document was created using
DOMImplementation.createDocument. |
DOMConfiguration |
getDomConfig()
The configuration used when
Document.normalizeDocument()
is invoked. |
Node |
getFirstChild()
Get the first child node of the element
|
String |
getInputEncoding()
An attribute specifying the encoding used for this document at the time
of the parsing.
|
Hashtable |
getKeyIndex(KeyManager keymanager,
int fingerprint)
Get the index for a given key
|
Node |
getLastChild()
Get the last child node of the element
|
int |
getLineNumber()
Get the line number of this root node.
|
protected int |
getLineNumber(int sequence)
Get the line number for an element.
|
NamePool |
getNamePool()
Get the name pool used for the names in this document
|
Node |
getNextSibling()
Get next sibling - always null
|
NodeFactory |
getNodeFactory()
Get the node factory that was used to build this document
|
short |
getNodeType()
Return the type of node.
|
String |
getNodeValue()
Get the node value as defined in the DOM.
|
protected NodeImpl |
getNthChild(int n)
Get the nth child node of the element (numbering from 0)
|
Node |
getPreviousSibling()
Get previous sibling - always null
|
protected long |
getSequenceNumber()
Get the node sequence number (in document order).
|
boolean |
getStrictErrorChecking()
An attribute specifying whether error checking is enforced or not.
|
String |
getStringValue()
Return the string-value of the node, that is, the concatenation
of the character content of all descendent elements and text nodes.
|
String |
getSystemId()
Get the system id of this root node
|
protected String |
getSystemId(int seq)
Get the system id of an element in the document
|
String |
getUnparsedEntity(String name)
Get the unparsed entity with a given name
|
String |
getXmlEncoding()
An attribute specifying, as part of the XML declaration, the encoding of this document.
|
boolean |
getXmlStandalone()
An attribute specifying, as part of the XML declaration, whether this document is standalone.
|
String |
getXmlVersion()
An attribute specifying, as part of the XML declaration, the version number of this document.
|
boolean |
hasChildNodes()
Determine if the node has any children.
|
void |
normalizeDocument()
This method acts as if the document was going through a save and load
cycle, putting the document in a "normal" form.
|
void |
removeChild(int index)
Remove node at given index.
|
Node |
renameNode(Node n,
String namespaceURI,
String qualifiedName)
Rename an existing node of type
ELEMENT_NODE or
ATTRIBUTE_NODE. |
void |
renumberChildren()
Renumber the children of a given parent node.
|
NodeInfo |
selectID(String id)
Get the element with a given ID.
|
protected void |
setCharacterBuffer(StringBuffer buffer)
Set the character buffer
|
protected void |
setDocumentElement(ElementImpl e)
Set the top-level element of the document (variously called the root element or the
document element).
|
void |
setDocumentURI(String documentURI)
The location of the document or
null if undefined or if
the Document was created using
DOMImplementation.createDocument. |
void |
setKeyIndex(KeyManager keymanager,
int fingerprint,
Hashtable keyindex)
Set the index for a given key.
|
protected void |
setLineNumber(int sequence,
int line)
Set the line number for an element.
|
void |
setLineNumbering()
Set line numbering on
|
void |
setNamePool(NamePool pool)
Set the name pool used for all names in this document
|
void |
setNodeFactory(NodeFactory factory)
Set the node factory that was used to build this document
|
void |
setStrictErrorChecking(boolean strictErrorChecking)
An attribute specifying whether error checking is enforced or not.
|
protected void |
setSystemId(int seq,
String uri)
Set the system id of an element in the document
|
void |
setSystemId(String uri)
Set the system id of this node
|
protected void |
setUnparsedEntity(String name,
String uri)
Set an unparsed entity URI associated with this document.
|
void |
setXmlStandalone(boolean xmlStandalone)
An attribute specifying, as part of the XML declaration, whether this document is standalone.
|
void |
setXmlVersion(String xmlVersion)
An attribute specifying, as part of the XML declaration, the version number of this document.
|
void |
useChildrenArray(NodeImpl[] array)
Supply an array to be used for the array of children.
|
compareOrder, getAttributes, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getNextInDocument, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getURI, hasAttributes, isSameNodeInfo, outputNamespaceNodes, removeNodeappendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getLength, getName, getNamespaceURI, getNodeName, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supportsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompareOrder, copyStringValue, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getParent, getPrefix, getStringValue, getURI, hasChildNodes, isSameNodeInfo, outputNamespaceNodescreateAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNodeappendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDataprotected void setCharacterBuffer(StringBuffer buffer)
public final StringBuffer getCharacterBuffer()
public void setNamePool(NamePool pool)
setNamePool in interface DocumentInfopublic NamePool getNamePool()
getNamePool in interface DocumentInfogetNamePool in class NodeImplpublic void setNodeFactory(NodeFactory factory)
public NodeFactory getNodeFactory()
protected void setDocumentElement(ElementImpl e)
e - the top-level elementpublic void setSystemId(String uri)
setSystemId in interface SourcesetSystemId in class NodeImplpublic String getSystemId()
getSystemId in interface NodeInfogetSystemId in interface SourcegetSystemId in interface SourceLocatorgetSystemId in class NodeImplpublic String getBaseURI()
getBaseURI in interface NodeInfogetBaseURI in interface NodegetBaseURI in class NodeImplprotected void setSystemId(int seq,
String uri)
protected String getSystemId(int seq)
public void setLineNumbering()
protected void setLineNumber(int sequence,
int line)
protected int getLineNumber(int sequence)
public int getLineNumber()
getLineNumber in interface NodeInfogetLineNumber in interface SourceLocatorgetLineNumber in class NodeImplpublic final short getNodeType()
getNodeType in interface NodeInfogetNodeType in interface Nodepublic final Node getNextSibling()
getNextSibling in interface NodegetNextSibling in class NodeImplpublic final Node getPreviousSibling()
getPreviousSibling in interface NodegetPreviousSibling in class NodeImplpublic Element getDocumentElement()
getDocumentElement in interface DocumentgetDocumentElement in class NodeImplpublic DocumentInfo getDocumentRoot()
getDocumentRoot in interface NodeInfogetDocumentRoot in class NodeImplpublic String generateId()
generateId in interface NodeInfogenerateId in class NodeImplprotected AxisEnumeration getAllElements(int fingerprint)
public NodeInfo selectID(String id)
selectID in interface DocumentInfoid - The unique ID of the required element, previously registered using registerID()public Hashtable getKeyIndex(KeyManager keymanager, int fingerprint)
getKeyIndex in interface DocumentInfokeymanager - The key manager managing this keyfingerprint - The fingerprint of the name of the key (unique with the key manager)public void setKeyIndex(KeyManager keymanager, int fingerprint, Hashtable keyindex)
setKeyIndex in interface DocumentInfokeymanager - The key manager managing this keyfingerprint - The fingerprint of the name of the key (unique with the key manager)keyindex - the index, in the form of a Hashtable that
maps the key value to a Vector of nodes having that key value. Or the String
"under construction", indicating that the index is being built.protected void setUnparsedEntity(String name, String uri)
public String getUnparsedEntity(String name)
getUnparsedEntity in interface DocumentInfoname - the name of the entitypublic void copy(Outputter out) throws TransformerException
copy in interface NodeInfoTransformerExceptionpublic Node adoptNode(Node source) throws DOMException
adoptNode in interface Documentsource - The node to move into this document.null if this operation
fails, such as when the source node comes from a different
implementation.DOMException - NOT_SUPPORTED_ERR: Raised if the source node is of type
DOCUMENT, DOCUMENT_TYPE.
public String getDocumentURI()
null if undefined or if
the Document was created using
DOMImplementation.createDocument. No lexical checking is
performed when setting this attribute; this could result in a
null value returned when using Node.baseURI
.
Document supports the feature
"HTML" [DOM Level 2 HTML]
, the href attribute of the HTML BASE element takes precedence over
this attribute when computing Node.baseURI.getDocumentURI in interface Documentpublic DOMConfiguration getDomConfig()
Document.normalizeDocument()
is invoked.getDomConfig in interface Documentpublic String getInputEncoding()
null when it is not known, such
as when the Document was created in memory.getInputEncoding in interface Documentpublic boolean getStrictErrorChecking()
false, the implementation is free to not test
every possible error case normally defined on DOM operations, and not
raise any DOMException on DOM operations or report
errors while using Document.normalizeDocument(). In case
of error, the behavior is undefined. This attribute is
true by default.getStrictErrorChecking in interface Documentpublic String getXmlEncoding()
null when
unspecified or when it is not known, such as when the
Document was created in memory.getXmlEncoding in interface Documentpublic boolean getXmlStandalone()
false when
unspecified.
Note: No verification is done on the value when setting
this attribute. Applications should use
Document.normalizeDocument() with the "validate"
parameter to verify if the value matches the validity
constraint for standalone document declaration as defined in [XML 1.0].
getXmlStandalone in interface Documentpublic String getXmlVersion()
"1.0".getXmlVersion in interface Documentpublic void normalizeDocument()
normalizeDocument in interface Documentpublic Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
ELEMENT_NODE or
ATTRIBUTE_NODE.renameNode in interface Documentn - The node to rename.namespaceURI - The new namespace URI.qualifiedName - The new qualified name.DOMException - NOT_SUPPORTED_ERR: Raised when the type of the specified node is
neither ELEMENT_NODE nor ATTRIBUTE_NODE,
or if the implementation does not support the renaming of the
document element.
Document.xmlVersion attribute.
qualifiedName is a
malformed qualified name, if the qualifiedName has a
prefix and the namespaceURI is null, or
if the qualifiedName has a prefix that is "xml" and
the namespaceURI is different from "
http://www.w3.org/XML/1998/namespace" [XML Namespaces]
. Also raised, when the node being renamed is an attribute, if the
qualifiedName, or its prefix, is "xmlns" and the
namespaceURI is different from "http://www.w3.org/2000/xmlns/".public void setDocumentURI(String documentURI)
null if undefined or if
the Document was created using
DOMImplementation.createDocument. No lexical checking is
performed when setting this attribute; this could result in a
null value returned when using Node.baseURI
.
Document supports the feature
"HTML" [DOM Level 2 HTML]
, the href attribute of the HTML BASE element takes precedence over
this attribute when computing Node.baseURI.setDocumentURI in interface Documentpublic void setStrictErrorChecking(boolean strictErrorChecking)
false, the implementation is free to not test
every possible error case normally defined on DOM operations, and not
raise any DOMException on DOM operations or report
errors while using Document.normalizeDocument(). In case
of error, the behavior is undefined. This attribute is
true by default.setStrictErrorChecking in interface Documentpublic void setXmlStandalone(boolean xmlStandalone)
throws DOMException
false when
unspecified.
Note: No verification is done on the value when setting
this attribute. Applications should use
Document.normalizeDocument() with the "validate"
parameter to verify if the value matches the validity
constraint for standalone document declaration as defined in [XML 1.0].
setXmlStandalone in interface DocumentDOMException - NOT_SUPPORTED_ERR: Raised if this document does not support the
"XML" feature.public void setXmlVersion(String xmlVersion) throws DOMException
"1.0". If this document does not support the "XML"
feature, the value is always null. Changing this
attribute will affect methods that check for invalid characters in
XML names. Application should invoke
Document.normalizeDocument() in order to check for
invalid characters in the Nodes that are already part of
this Document.
DOMImplementation.hasFeature(feature, version) method
with parameter values "XMLVersion" and "1.0" (respectively) to
determine if an implementation supports [XML 1.0]. DOM
applications may use the same method with parameter values
"XMLVersion" and "1.1" (respectively) to determine if an
implementation supports [XML 1.1]. In both
cases, in order to support XML, an implementation must also support
the "XML" feature defined in this specification. Document
objects supporting a version of the "XMLVersion" feature must not
raise a NOT_SUPPORTED_ERR exception for the same version
number when using Document.xmlVersion.setXmlVersion in interface DocumentDOMException - NOT_SUPPORTED_ERR: Raised if the version is set to a value that is
not supported by this Document or if this document
does not support the "XML" feature.protected final long getSequenceNumber()
getSequenceNumber in class NodeImplpublic final boolean hasChildNodes()
hasChildNodes in interface NodeInfohasChildNodes in interface NodehasChildNodes in class NodeImpltrue if the node has any children,
false if the node has no children.public final AxisEnumeration enumerateChildren(NodeTest test)
public final Node getFirstChild()
getFirstChild in interface NodegetFirstChild in class NodeImplpublic final Node getLastChild()
getLastChild in interface NodegetLastChild in class NodeImplpublic final NodeList getChildNodes()
NodeList that contains all children of this node. If
there are no children, this is a NodeList containing no
nodes.getChildNodes in interface NodegetChildNodes in class NodeImplprotected final NodeImpl getNthChild(int n)
public String getStringValue()
public void copyStringValue(Outputter out) throws TransformerException
copyStringValue in interface NodeInfocopyStringValue in class AbstractNodeTransformerExceptionpublic void useChildrenArray(NodeImpl[] array)
public void addChild(NodeImpl node, int index)
public void removeChild(int index)
public void renumberChildren()
public void dropChildren()
public void compact(int size)
public String getNodeValue()
getNodeValue in interface NodegetNodeValue in class AbstractNode