public class DocumentImpl extends ParentNodeImpl implements Document
getDocumentElement()
), to the DTD if one exists (getDoctype()
,
and to all node operations.
Several methods create new nodes of all basic types (comment, text, element,
etc.). These methods create new nodes but do not place them in the document
tree. The nodes may be placed in the document tree using Node.appendChild(org.w3c.dom.Node)
or Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
, or
they may be placed in some other document tree.
Notes:
Node.DOCUMENT_NODE
Document
,
ParentNodeImpl
,
DOMImplementation
ATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_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
Modifier | Constructor and Description |
---|---|
|
DocumentImpl() |
protected |
DocumentImpl(String namespaceURI,
String qualifiedName,
DocumentType docType)
Constructor for new document requires qualified name to create document
element.
|
protected |
DocumentImpl(String namespaceURI,
String qualifiedName,
DocumentType docType,
ElementFactory elementFactory)
[JF] Constructor for new document requires qualified name to create
document element.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire(long lockTimeout)
Called to acquire access to a possible locked resource.
|
Node |
adoptNode(Node source) |
Object |
clone() |
protected void |
cloneInto(NodeImpl into,
boolean deep)
This clone method is called after a new node has been constructed to
copy the contents of this node into the new one.
|
Node |
cloneNode(boolean deep) |
short |
compareDocumentPosition(Node other) |
Attr |
createAttribute(String name) |
Attr |
createAttribute(String name,
String defValue)
Creates an attribute with the default value specified in the DTD.
|
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName) |
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName,
String defValue) |
CDATASection |
createCDATASection(String data) |
Comment |
createComment(String data) |
DocumentFragment |
createDocumentFragment() |
Element |
createElement(String tagName) |
Element |
createElementNS(String namespaceURI,
String qualifiedName) |
EntityReference |
createEntityReference(String name) |
org.w3c.dom.traversal.NodeIterator |
createNodeIterator(Node root,
int whatToShow,
org.w3c.dom.traversal.NodeFilter filter,
boolean entityRefExpansion) |
ProcessingInstruction |
createProcessingInstruction(String target,
String data) |
Text |
createTextNode(String data) |
boolean |
equals(Object other)
Returns true if this node and other are identical by content but
not context.
|
String |
getBaseURI() |
DocumentType |
getDoctype() |
Element |
getDocumentElement() |
String |
getDocumentURI() |
DOMConfiguration |
getDomConfig() |
Element |
getElementById(String elementId) |
NodeList |
getElementsByTagName(String tagName) |
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName) |
String |
getEncoding()
DOM Level 3 WD - Experimental.
|
Object |
getFeature(String feature,
String version) |
DOMImplementation |
getImplementation() |
String |
getInputEncoding() |
String |
getNamespaceURI() |
short |
getNodeType()
Abstract method must be implemented by each node class.
|
boolean |
getStandalone()
DOM Level 3 WD - Experimental.
|
boolean |
getStrictErrorChecking() |
String |
getTextContent() |
Object |
getUserData(String key) |
String |
getVersion()
DOM Level 3 WD - Experimental.
|
String |
getXmlEncoding() |
boolean |
getXmlStandalone() |
String |
getXmlVersion() |
boolean |
hasAttributes() |
Node |
importNode(Node importedNode,
boolean deep)
NOT IMPLEMENTED
|
boolean |
isDefaultNamespace(String namespaceURI) |
boolean |
isEqualNode(Node arg) |
boolean |
isSameNode(Node other) |
boolean |
isSupported(String feature,
String version) |
void |
lock()
Obtains a lock, preventing other threads from gaining access to the
locked resource.
|
String |
lookupNamespaceURI(String prefix) |
String |
lookupPrefix(String namespaceURI) |
void |
normalizeDocument() |
void |
registerElement(String tagName,
Class elementClass)
Register an application-defined element type.
|
Node |
renameNode(Node n,
String namespaceURI,
String qualifiedName) |
void |
setDocumentURI(String documentURI) |
void |
setEncoding(String value)
DOM Level 3 WD - Experimental.
|
void |
setNodeValue(String value)
Changes the value of the node.
|
void |
setStandalone(boolean value)
DOM Level 3 WD - Experimental.
|
void |
setStrictErrorChecking(boolean check) |
void |
setTextContent(String textContent) |
Object |
setUserData(String key,
Object data,
UserDataHandler handler) |
void |
setVersion(String value)
DOM Level 3 WD - Experimental.
|
void |
setXmlStandalone(boolean xmlStandalone) |
void |
setXmlVersion(String xmlVersion) |
String |
toString() |
void |
unlock()
Releases a lock, so other thread may gain access to the resource.
|
void |
useElementFactory(ElementFactory elementFactory)
Sets the element factory for this document.
|
appendChild, castNewChild, castOldChild, createNodeIterator, getChildNodes, getFirstChild, getLastChild, hasChildNodes, insertBefore, normalize, removeChild, removeInnerIterator, replaceChild
getAttributes, getLocalName, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, isReadOnly, makeReadOnly, setOwnerDocument, setPrefix, supports
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, normalize, removeChild, replaceChild, setPrefix
protected DocumentImpl(String namespaceURI, String qualifiedName, DocumentType docType) throws DOMException
namespaceURI
- The namespace URI, or nullqualifiedName
- The qualified name of the document elementdocType
- The type of the document, or nullDOMException
- The document type is already used, or the qualified
name is invalidprotected DocumentImpl(String namespaceURI, String qualifiedName, DocumentType docType, ElementFactory elementFactory) throws DOMException
namespaceURI
- The namespace URI, or nullqualifiedName
- The qualified name of the document elementdocType
- The type of the document, or nullDOMException
- The document type is already used, or the qualified
name is invalidpublic DocumentImpl()
public short getNodeType()
NodeImpl
getNodeType
in interface Node
getNodeType
in class NodeImpl
Node.getNodeType()
public final void setNodeValue(String value)
NodeImpl
Element Not supported Attr Supported Text Supported CDATASection Supported EntityReference Not supported Entity Not supported ProcessingInstruction Supported Comment Supported Document Not supported DocumentType Not supported DocumentFragment Not supported Notation Not supportedFor most node types, if the value is set to null,
NodeImpl.getNodeValue()
will return an empty string instead.setNodeValue
in interface Node
setNodeValue
in class NodeImpl
value
- New value of nodepublic final DocumentType getDoctype()
getDoctype
in interface Document
public final DOMImplementation getImplementation()
getImplementation
in interface Document
public Element getDocumentElement()
getDocumentElement
in interface Document
public Element createElement(String tagName) throws DOMException
createElement
in interface Document
DOMException
public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
createElementNS
in interface Document
DOMException
public final DocumentFragment createDocumentFragment()
createDocumentFragment
in interface Document
public final Text createTextNode(String data)
createTextNode
in interface Document
public final Comment createComment(String data)
createComment
in interface Document
public final CDATASection createCDATASection(String data) throws DOMException
createCDATASection
in interface Document
DOMException
public final ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
createProcessingInstruction
in interface Document
DOMException
public final Attr createAttribute(String name) throws DOMException
createAttribute
in interface Document
DOMException
public final Attr createAttribute(String name, String defValue) throws DOMException
name
- The name of the attributedefValue
- The default value of the attributeDOMException
public final Attr createAttributeNS(String namespaceURI, String qualifiedName, String defValue) throws DOMException
DOMException
public final Attr createAttributeNS(String namespaceURI, String qualifiedName)
createAttributeNS
in interface Document
public final EntityReference createEntityReference(String name) throws DOMException
createEntityReference
in interface Document
DOMException
public NodeList getElementsByTagName(String tagName)
getElementsByTagName
in interface Document
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
getElementsByTagNameNS
in interface Document
public org.w3c.dom.traversal.NodeIterator createNodeIterator(Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityRefExpansion)
public Element getElementById(String elementId)
getElementById
in interface Document
public void registerElement(String tagName, Class elementClass)
createElement(java.lang.String)
, an object of the specified class is created and
returned. This allows applications to define classes for specific
element types.tagName
- The name of the element tagelementClass
- Class derived from ElementImpl
,
used to construct the elementpublic void useElementFactory(ElementFactory elementFactory)
elementFactory
- The new element factorypublic final Node importNode(Node importedNode, boolean deep) throws DOMException
importNode
in interface Document
DOMException
public final String getNamespaceURI()
getNamespaceURI
in interface Node
getNamespaceURI
in class NodeImpl
public void lock() throws RuntimeException
unlock()
is called. Attempts to call acquire(long)
from
another thread will be blocked.
If the resource is already locked by another thread, the method will block until the lock is released or until the block has timedout.
lock()
may be called any number of times, and unlock()
must be called that number of times to release the lock.
RuntimeException
unlock()
public void unlock()
unlock()
must be called as many times as lock()
was called to
release the lock. unlock()
may be called an additional number of
times, if so required by the implementation (e.g. to assure that a lock
is released at the end of a thread).lock()
public void acquire(long lockTimeout) throws RuntimeException
RuntimeException
lock()
,
unlock()
public boolean equals(Object other)
NodeImpl
NodeImpl.equals(java.lang.Object)
on each pair
Note that for large document roots, the equality operation can be very expensive.
equals
in class ParentNodeImpl
other
- The other node to test for equalityprotected void cloneInto(NodeImpl into, boolean deep)
NodeImpl
NodeImpl.equals(java.lang.Object)
).
into must be a valid node of the exact same class as this one. deep is true if deep cloning (includes all children nodes) is to be performed. If deep is false, the clone might not pass the equality test.
Derived classes override and call this method to add per-class variable
copying. This method is called by Node.cloneNode(boolean)
and the default
Object.clone()
method.
Contents cloning duplicates the node's name and value, and its children. It does not duplicate it's context, that is, the node's parent or sibling. Initially a clone node has no parents or siblings. However, the node does belong to the same document, since all nodes must belong to some document. The cloned node is never read-only.
cloneInto
in class ParentNodeImpl
into
- A node into which to duplicate this onedeep
- True if deep cloning is requiredpublic String getEncoding()
public boolean getStandalone()
public void setStandalone(boolean value)
public boolean getStrictErrorChecking()
getStrictErrorChecking
in interface Document
public void setStrictErrorChecking(boolean check)
setStrictErrorChecking
in interface Document
public String getVersion()
public void setVersion(String value)
public void setEncoding(String value)
public String getDocumentURI()
getDocumentURI
in interface Document
public DOMConfiguration getDomConfig()
getDomConfig
in interface Document
public String getInputEncoding()
getInputEncoding
in interface Document
public String getXmlEncoding()
getXmlEncoding
in interface Document
public boolean getXmlStandalone()
getXmlStandalone
in interface Document
public String getXmlVersion()
getXmlVersion
in interface Document
public void normalizeDocument()
normalizeDocument
in interface Document
public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
renameNode
in interface Document
DOMException
public void setDocumentURI(String documentURI)
setDocumentURI
in interface Document
public void setXmlStandalone(boolean xmlStandalone) throws DOMException
setXmlStandalone
in interface Document
DOMException
public void setXmlVersion(String xmlVersion) throws DOMException
setXmlVersion
in interface Document
DOMException
public short compareDocumentPosition(Node other) throws DOMException
compareDocumentPosition
in interface Node
DOMException
public String getBaseURI()
getBaseURI
in interface Node
public Object getFeature(String feature, String version)
getFeature
in interface Node
public String getTextContent() throws DOMException
getTextContent
in interface Node
DOMException
public Object getUserData(String key)
getUserData
in interface Node
public boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace
in interface Node
public boolean isEqualNode(Node arg)
isEqualNode
in interface Node
public boolean isSameNode(Node other)
isSameNode
in interface Node
public String lookupNamespaceURI(String prefix)
lookupNamespaceURI
in interface Node
public String lookupPrefix(String namespaceURI)
lookupPrefix
in interface Node
public void setTextContent(String textContent) throws DOMException
setTextContent
in interface Node
DOMException
public Object setUserData(String key, Object data, UserDataHandler handler)
setUserData
in interface Node
public boolean hasAttributes()
hasAttributes
in interface Node
public boolean isSupported(String feature, String version)
isSupported
in interface Node
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.