public class HdxDocument extends Object implements Document
org.w3c.dom.Document
interface. This implements allows clients to create mutually
consistent implementations of the various org.w3c.dom
interfaces. It also extends the interface by adding creation
method createElement(HdxFacade).
To avoid confusion, note that, despite its name,
HdxDocumentFactory is not a general factory
for creating empty instances of HdxDocument. If you wish
to create a blank HdxDocument (perhaps because you are
implementing HdxDocumentFactory.makeHdxDocument(java.net.URL)), you do so
simply with a call to
HdxDOMImplementation.getInstance().createDocument(null,<el>,null)(where
<el> represents the name of the document element.
Note that only DOM Level 2 methods are currently implemented. If this class is built using JDK1.5, then the DOM Level 3 methods will be present, but they do not implement the functionality defined by the DOM Level 3 specification (mostly they throw NOT_SUPPORTED_ERR type DOMExceptions).
| Modifier and Type | Class and Description |
|---|---|
static class |
HdxDocument.NodeUtil
Collection of rather ragged Node utilities.
|
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 and Description |
|---|
HdxDocument() |
| Modifier and Type | Method and Description |
|---|---|
Node |
adoptNode(Node source) |
Node |
appendChild(Node newChild) |
Object |
clone()
Creates and returns a copy of this Node.
|
protected Object |
clone(boolean deep)
Creates and returns a copy of this Node.
|
Node |
cloneNode(boolean deep)
Returns a duplicate of this Node.
|
short |
compareDocumentPosition(Node other)
Not implemented
|
Attr |
createAttribute(String name) |
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName) |
CDATASection |
createCDATASection(String data) |
Comment |
createComment(String data) |
DocumentFragment |
createDocumentFragment() |
Element |
createElement(HdxFacade facade)
Creates an element which manages its children using a
HdxFacade. |
Element |
createElement(String tagName) |
Element |
createElementNS(String namespaceURI,
String qualifiedName) |
EntityReference |
createEntityReference(String name) |
ProcessingInstruction |
createProcessingInstruction(String target,
String data) |
Text |
createTextNode(String data) |
boolean |
equals(Object t)
Indicates whether some other object is `equal to' this one.
|
NamedNodeMap |
getAttributes() |
String |
getBaseURI()
Not implemented
|
NodeList |
getChildNodes() |
DocumentType |
getDoctype() |
Element |
getDocumentElement() |
String |
getDocumentURI() |
DOMConfiguration |
getDomConfig()
Not implemented
|
Element |
getElementById(String elementId) |
NodeList |
getElementsByTagName(String tagname) |
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName)
Returns a NodeList of all the descendant Elements with a given
local name and namespace URI in the order in which they are
encountered in a preorder traversal of this Element tree.
|
Object |
getFeature(String feature,
String version)
Not implemented
|
Node |
getFirstChild() |
DOMImplementation |
getImplementation() |
String |
getInputEncoding()
Not implemented
|
Node |
getLastChild() |
String |
getLocalName()
Returns the local part of the qualified name of this node.
|
String |
getNamespaceURI() |
Node |
getNextSibling() |
String |
getNodeName() |
short |
getNodeType() |
String |
getNodeValue() |
Document |
getOwnerDocument() |
Node |
getParentNode() |
String |
getPrefix() |
Node |
getPreviousSibling() |
boolean |
getStrictErrorChecking()
Not implemented
|
String |
getTextContent() |
Object |
getUserData(String key)
Not implemented
|
String |
getXmlEncoding()
Not implemented
|
boolean |
getXmlStandalone()
Not implemented
|
String |
getXmlVersion()
Not implemented
|
boolean |
hasAttributes() |
boolean |
hasChildNodes() |
int |
hashCode() |
Node |
importNode(Node importedNode,
boolean deep) |
Node |
insertBefore(Node newChild,
Node refChild) |
boolean |
isDefaultNamespace(String namespaceURI)
Not implemented
|
boolean |
isEqualNode(Node node) |
boolean |
isSameNode(Node other) |
boolean |
isSupported(String feature,
String version) |
String |
lookupNamespaceURI(String prefix)
Not implemented
|
String |
lookupPrefix(String namespaceURI)
Not implemented
|
void |
normalize() |
void |
normalizeDocument()
Not implemented
|
Node |
removeChild(Node oldChild) |
Node |
renameNode(Node n,
String namespaceURI,
String qualifiedName)
Not implemented
|
Node |
replaceChild(Node newChild,
Node oldChild) |
void |
setDocumentURI(String documentURI) |
void |
setInputEncoding(String value)
Not implemented
|
void |
setNodeValue(String nodeValue) |
void |
setPrefix(String prefix) |
void |
setStrictErrorChecking(boolean check)
Not implemented
|
void |
setTextContent(String textContent) |
Object |
setUserData(String key,
Object data,
UserDataHandler handler)
Not implemented
|
void |
setXmlEncoding(String value)
Not implemented
|
void |
setXmlStandalone(boolean value)
Not implemented
|
void |
setXmlVersion(String value)
Not implemented
|
String |
toString() |
protected void |
unimplementedMethod(String methodName) |
finalize, getClass, notify, notifyAll, wait, wait, waitappendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDatapublic DocumentType getDoctype()
getDoctype in interface Documentpublic String getNodeName()
getNodeName in interface Nodepublic DOMImplementation getImplementation()
getImplementation in interface Documentpublic Element getDocumentElement()
getDocumentElement in interface Documentpublic Element createElement(String tagName) throws DOMException
createElement in interface DocumentDOMExceptionpublic Element createElement(HdxFacade facade) throws DOMException
HdxFacade. The tagName of the
resulting element is that corresponding to the HdxResourceType.
This is an extension to the org.w3c.dom.Document
interface.
The resulting element has the property that if it is cloned
using clone(), the resulting element is also a
facade for the underlying object; if it is cloned using
cloneNode, however, the resulting element is an
ordinary element, which is now independent of the
underlying object.
facade - an implementation of the HdxFacade
interfaceIllegalArgumentException - if the facade is invalid.DOMExceptionpublic DocumentFragment createDocumentFragment()
createDocumentFragment in interface Documentpublic Text createTextNode(String data)
createTextNode in interface Documentpublic Comment createComment(String data)
createComment in interface Documentpublic CDATASection createCDATASection(String data) throws DOMException
createCDATASection in interface DocumentDOMExceptionpublic ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
createProcessingInstruction in interface DocumentDOMExceptionpublic Attr createAttribute(String name) throws DOMException
createAttribute in interface DocumentDOMExceptionpublic 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 Node importNode(Node importedNode, boolean deep) throws DOMException
importNode in interface DocumentDOMExceptionpublic Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
createElementNS in interface DocumentDOMExceptionpublic Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException
createAttributeNS in interface DocumentDOMExceptionpublic Element getElementById(String elementId)
getElementById in interface Documentpublic Node renameNode(Node n, String namespaceURI, String qualifiedName)
renameNode in interface Documentpublic void normalizeDocument()
normalizeDocument in interface Documentpublic DOMConfiguration getDomConfig()
getDomConfig in interface Documentpublic void setDocumentURI(String documentURI)
setDocumentURI in interface Documentpublic String getDocumentURI()
getDocumentURI in interface Documentpublic void setStrictErrorChecking(boolean check)
setStrictErrorChecking in interface Documentpublic boolean getStrictErrorChecking()
getStrictErrorChecking in interface Documentpublic void setXmlVersion(String value)
setXmlVersion in interface Documentpublic String getXmlVersion()
getXmlVersion in interface Documentpublic void setXmlStandalone(boolean value)
setXmlStandalone in interface Documentpublic boolean getXmlStandalone()
getXmlStandalone in interface Documentpublic void setXmlEncoding(String value)
public String getXmlEncoding()
getXmlEncoding in interface Documentpublic String getInputEncoding()
getInputEncoding in interface Documentpublic void setInputEncoding(String value)
public String getNodeValue() throws DOMException
getNodeValue in interface NodeDOMExceptionpublic void setNodeValue(String nodeValue) throws DOMException
setNodeValue in interface NodeDOMExceptionpublic short getNodeType()
getNodeType in interface Nodepublic boolean hasAttributes()
hasAttributes in interface Nodepublic NamedNodeMap getAttributes()
getAttributes in interface Nodepublic Node getParentNode()
getParentNode in interface Nodepublic NodeList getChildNodes()
getChildNodes in interface Nodepublic Node getFirstChild()
getFirstChild in interface Nodepublic Node getLastChild()
getLastChild in interface Nodepublic Node getPreviousSibling()
getPreviousSibling in interface Nodepublic Node getNextSibling()
getNextSibling in interface Nodepublic Document getOwnerDocument()
getOwnerDocument in interface Nodepublic Node insertBefore(Node newChild, Node refChild) throws DOMException
insertBefore in interface NodeIllegalArgumentException - (unchecked) if newChild is nullDOMExceptionpublic Node replaceChild(Node newChild, Node oldChild) throws DOMException
replaceChild in interface NodeIllegalArgumentException - (unchecked) if newChild or oldChild is nullDOMExceptionpublic Node removeChild(Node oldChild) throws DOMException
removeChild in interface NodeIllegalArgumentException - (unchecked) if oldChild is nullDOMExceptionpublic Node appendChild(Node newChild) throws DOMException
appendChild in interface NodeIllegalArgumentException - (unchecked) if newChild is nullDOMExceptionpublic boolean hasChildNodes()
hasChildNodes in interface Nodepublic Node cloneNode(boolean deep)
clone(boolean) method is that the node returned
by this method has no parent.
Although it's not completely specified in the documentation, here, the cloned node does
not not retain references to the original's siblings. If the
clone is a shallow one, then the result node has no children either.
Implementation node: classes which extend
HdxNode should preserve the distinction between
cloneNode() and clone(). You may use
clone(false) to copy the object fields if that is
convenient, but we recurse using
cloneNode(true). This means that we can implement
different behaviour for the two methods if we need to, in
extending classes. This distinction is admittedly
under-specified right now: if you are writing code where the
details matter, you might want to contact the code authors to
see if (a) you are attempting something you oughtn't (wicked!), or
(b) it's time to pin this specification down more precisely.
public Object clone()
cloneNode(boolean)
is that the clone and the original share a reference to their parent.protected Object clone(boolean deep)
cloneNode(boolean)
is that the clone and the original share a reference to their parent.deep - if true, recursively clone the subtree under
this node; if false, clone only the node itselfpublic boolean equals(Object t)
Two Nodes are equal to one another if their types, names and
values are equal. However, to avoid
a potentially very expensive recursion, this test does
not depend on whether the two nodes' children
are also equal.
Note that this is overridden for Element tests.
public boolean isSupported(String feature, String version)
isSupported in interface Nodepublic String getNamespaceURI()
getNamespaceURI in interface Nodepublic void setPrefix(String prefix) throws DOMException
setPrefix in interface NodeDOMExceptionpublic String getLocalName()
getLocalName in interface Nodepublic Object setUserData(String key, Object data, UserDataHandler handler)
setUserData in interface Nodepublic Object getUserData(String key)
getUserData in interface Nodepublic Object getFeature(String feature, String version)
getFeature in interface Nodepublic boolean isEqualNode(Node node)
isEqualNode in interface Nodepublic String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodepublic boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace in interface Nodepublic String lookupPrefix(String namespaceURI)
lookupPrefix in interface Nodepublic boolean isSameNode(Node other)
isSameNode in interface Nodepublic void setTextContent(String textContent)
setTextContent in interface Nodepublic String getTextContent()
getTextContent in interface Nodepublic short compareDocumentPosition(Node other)
compareDocumentPosition in interface Nodepublic String getBaseURI()
getBaseURI in interface Nodeprotected void unimplementedMethod(String methodName) throws UnsupportedOperationException
UnsupportedOperationExceptionCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.