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,
DOMImplementationATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_NODEATTRIBUTE_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, replaceChildgetAttributes, getLocalName, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, isReadOnly, makeReadOnly, setOwnerDocument, setPrefix, supportsfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, normalize, removeChild, replaceChild, setPrefixprotected 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()
NodeImplgetNodeType in interface NodegetNodeType in class NodeImplNode.getNodeType()public final void setNodeValue(String value)
NodeImplElement 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 NodesetNodeValue in class NodeImplvalue - New value of nodepublic final DocumentType getDoctype()
getDoctype in interface Documentpublic final DOMImplementation getImplementation()
getImplementation in interface Documentpublic Element getDocumentElement()
getDocumentElement in interface Documentpublic Element createElement(String tagName) throws DOMException
createElement in interface DocumentDOMExceptionpublic Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
createElementNS in interface DocumentDOMExceptionpublic final DocumentFragment createDocumentFragment()
createDocumentFragment in interface Documentpublic final Text createTextNode(String data)
createTextNode in interface Documentpublic final Comment createComment(String data)
createComment in interface Documentpublic final CDATASection createCDATASection(String data) throws DOMException
createCDATASection in interface DocumentDOMExceptionpublic final ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
createProcessingInstruction in interface DocumentDOMExceptionpublic final Attr createAttribute(String name) throws DOMException
createAttribute in interface DocumentDOMExceptionpublic final Attr createAttribute(String name, String defValue) throws DOMException
name - The name of the attributedefValue - The default value of the attributeDOMExceptionpublic final Attr createAttributeNS(String namespaceURI, String qualifiedName, String defValue) throws DOMException
DOMExceptionpublic final Attr createAttributeNS(String namespaceURI, String qualifiedName)
createAttributeNS in interface Documentpublic final EntityReference createEntityReference(String name) throws DOMException
createEntityReference in interface DocumentDOMExceptionpublic NodeList getElementsByTagName(String tagName)
getElementsByTagName in interface Documentpublic NodeList getElementsByTagNameNS(String namespaceURI, String localName)
getElementsByTagNameNS in interface Documentpublic 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 Documentpublic 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 DocumentDOMExceptionpublic final String getNamespaceURI()
getNamespaceURI in interface NodegetNamespaceURI in class NodeImplpublic 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.
RuntimeExceptionunlock()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
RuntimeExceptionlock(),
unlock()public boolean equals(Object other)
NodeImplNodeImpl.equals(java.lang.Object) on each pair
Note that for large document roots, the equality operation can be very expensive.
equals in class ParentNodeImplother - The other node to test for equalityprotected void cloneInto(NodeImpl into, boolean deep)
NodeImplNodeImpl.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 ParentNodeImplinto - 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 Documentpublic void setStrictErrorChecking(boolean check)
setStrictErrorChecking in interface Documentpublic String getVersion()
public void setVersion(String value)
public void setEncoding(String value)
public String getDocumentURI()
getDocumentURI in interface Documentpublic DOMConfiguration getDomConfig()
getDomConfig in interface Documentpublic String getInputEncoding()
getInputEncoding in interface Documentpublic String getXmlEncoding()
getXmlEncoding in interface Documentpublic boolean getXmlStandalone()
getXmlStandalone in interface Documentpublic String getXmlVersion()
getXmlVersion in interface Documentpublic void normalizeDocument()
normalizeDocument in interface Documentpublic Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
renameNode in interface DocumentDOMExceptionpublic void setDocumentURI(String documentURI)
setDocumentURI in interface Documentpublic void setXmlStandalone(boolean xmlStandalone)
throws DOMException
setXmlStandalone in interface DocumentDOMExceptionpublic void setXmlVersion(String xmlVersion) throws DOMException
setXmlVersion in interface DocumentDOMExceptionpublic short compareDocumentPosition(Node other) throws DOMException
compareDocumentPosition in interface NodeDOMExceptionpublic String getBaseURI()
getBaseURI in interface Nodepublic Object getFeature(String feature, String version)
getFeature in interface Nodepublic String getTextContent() throws DOMException
getTextContent in interface NodeDOMExceptionpublic Object getUserData(String key)
getUserData in interface Nodepublic boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace in interface Nodepublic boolean isEqualNode(Node arg)
isEqualNode in interface Nodepublic boolean isSameNode(Node other)
isSameNode in interface Nodepublic String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodepublic String lookupPrefix(String namespaceURI)
lookupPrefix in interface Nodepublic void setTextContent(String textContent) throws DOMException
setTextContent in interface NodeDOMExceptionpublic Object setUserData(String key, Object data, UserDataHandler handler)
setUserData in interface Nodepublic boolean hasAttributes()
hasAttributes in interface Nodepublic boolean isSupported(String feature, String version)
isSupported in interface NodePhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.