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, wait
appendChild, 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, setUserData
public DocumentType getDoctype()
getDoctype
in interface Document
public String getNodeName()
getNodeName
in interface Node
public 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 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.DOMException
public DocumentFragment createDocumentFragment()
createDocumentFragment
in interface Document
public Text createTextNode(String data)
createTextNode
in interface Document
public Comment createComment(String data)
createComment
in interface Document
public CDATASection createCDATASection(String data) throws DOMException
createCDATASection
in interface Document
DOMException
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
createProcessingInstruction
in interface Document
DOMException
public Attr createAttribute(String name) throws DOMException
createAttribute
in interface Document
DOMException
public 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 Node importNode(Node importedNode, boolean deep) throws DOMException
importNode
in interface Document
DOMException
public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
createElementNS
in interface Document
DOMException
public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException
createAttributeNS
in interface Document
DOMException
public Element getElementById(String elementId)
getElementById
in interface Document
public Node renameNode(Node n, String namespaceURI, String qualifiedName)
renameNode
in interface Document
public void normalizeDocument()
normalizeDocument
in interface Document
public DOMConfiguration getDomConfig()
getDomConfig
in interface Document
public void setDocumentURI(String documentURI)
setDocumentURI
in interface Document
public String getDocumentURI()
getDocumentURI
in interface Document
public void setStrictErrorChecking(boolean check)
setStrictErrorChecking
in interface Document
public boolean getStrictErrorChecking()
getStrictErrorChecking
in interface Document
public void setXmlVersion(String value)
setXmlVersion
in interface Document
public String getXmlVersion()
getXmlVersion
in interface Document
public void setXmlStandalone(boolean value)
setXmlStandalone
in interface Document
public boolean getXmlStandalone()
getXmlStandalone
in interface Document
public void setXmlEncoding(String value)
public String getXmlEncoding()
getXmlEncoding
in interface Document
public String getInputEncoding()
getInputEncoding
in interface Document
public void setInputEncoding(String value)
public String getNodeValue() throws DOMException
getNodeValue
in interface Node
DOMException
public void setNodeValue(String nodeValue) throws DOMException
setNodeValue
in interface Node
DOMException
public short getNodeType()
getNodeType
in interface Node
public boolean hasAttributes()
hasAttributes
in interface Node
public NamedNodeMap getAttributes()
getAttributes
in interface Node
public Node getParentNode()
getParentNode
in interface Node
public NodeList getChildNodes()
getChildNodes
in interface Node
public Node getFirstChild()
getFirstChild
in interface Node
public Node getLastChild()
getLastChild
in interface Node
public Node getPreviousSibling()
getPreviousSibling
in interface Node
public Node getNextSibling()
getNextSibling
in interface Node
public Document getOwnerDocument()
getOwnerDocument
in interface Node
public Node insertBefore(Node newChild, Node refChild) throws DOMException
insertBefore
in interface Node
IllegalArgumentException
- (unchecked) if newChild is nullDOMException
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
replaceChild
in interface Node
IllegalArgumentException
- (unchecked) if newChild or oldChild is nullDOMException
public Node removeChild(Node oldChild) throws DOMException
removeChild
in interface Node
IllegalArgumentException
- (unchecked) if oldChild is nullDOMException
public Node appendChild(Node newChild) throws DOMException
appendChild
in interface Node
IllegalArgumentException
- (unchecked) if newChild is nullDOMException
public boolean hasChildNodes()
hasChildNodes
in interface Node
public 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 Node
public String getNamespaceURI()
getNamespaceURI
in interface Node
public void setPrefix(String prefix) throws DOMException
setPrefix
in interface Node
DOMException
public String getLocalName()
getLocalName
in interface Node
public Object setUserData(String key, Object data, UserDataHandler handler)
setUserData
in interface Node
public Object getUserData(String key)
getUserData
in interface Node
public Object getFeature(String feature, String version)
getFeature
in interface Node
public boolean isEqualNode(Node node)
isEqualNode
in interface Node
public String lookupNamespaceURI(String prefix)
lookupNamespaceURI
in interface Node
public boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace
in interface Node
public String lookupPrefix(String namespaceURI)
lookupPrefix
in interface Node
public boolean isSameNode(Node other)
isSameNode
in interface Node
public void setTextContent(String textContent)
setTextContent
in interface Node
public String getTextContent()
getTextContent
in interface Node
public short compareDocumentPosition(Node other)
compareDocumentPosition
in interface Node
public String getBaseURI()
getBaseURI
in interface Node
protected void unimplementedMethod(String methodName) throws UnsupportedOperationException
UnsupportedOperationException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.