public abstract class AbstractXmlNode extends java.lang.Object implements XmlNode
XmlDocumentATTRIBUTE_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 |
|---|---|
protected |
AbstractXmlNode(org.w3c.dom.Node n,
XmlNodeFactory<? extends XmlNode> nodeFactory)
Constructs a new XmlNode.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends XmlNode> |
addChild(java.lang.Class<T> tagClass)
Adds an instance of the specified child class to this node.
|
XmlNode |
addChild(java.lang.String tagName)
Adds an instance of the specified child class to this node.
|
<T extends XmlNode> |
appendChild(java.lang.Class<T> tagClass)
Adds an instance of the specified child class to this node and appends
it to the child nodes of this node.
|
org.w3c.dom.Node |
appendChild(org.w3c.dom.Node newChild)
Adds the node
newChild to the end of the list of children
of this node. |
AbstractXmlNode |
appendDeepClone(AbstractXmlNode origin)
Appends a deep clone of the given node to the children of this node.
|
protected abstract boolean |
canContainChild(java.lang.String childName)
Can the specified sub-tag be contained within this node?
|
org.w3c.dom.Node |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy
constructor for nodes.
|
short |
compareDocumentPosition(org.w3c.dom.Node other)
Compares the reference node, i.e.
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getAttribute(java.lang.String attribute)
Convenient method to get the value of an attribute.
|
java.util.Collection<java.lang.String> |
getAttributeNames()
Returns a collection of permitted attribute names for the node.
|
org.w3c.dom.NamedNodeMap |
getAttributes()
A
NamedNodeMap containing the attributes of this node (if
it is an Element) or null otherwise. |
java.lang.String |
getBaseURI()
The absolute base URI of this node or
null if the
implementation wasn't able to obtain an absolute URI. |
org.w3c.dom.NodeList |
getChildNodes()
A
NodeList that contains all children of this node. |
<T extends XmlNode> |
getChildNodes(java.lang.Class<T> tagClass)
Return a collection of child nodes with the specified tag class.
|
<T extends XmlNode> |
getChildren()
Return a collection of all child nodes.
|
java.util.Collection<java.lang.String> |
getDefinedAttributeNames()
Retrieves a list of all attributes defined in this node.
|
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the specialized
APIs of the specified feature and version, as specified in .
|
org.w3c.dom.Node |
getFirstChild()
The first child of this node.
|
java.lang.String |
getFirstLevelTextContent()
Returns the text contents of this node, similar to
getTextContent() but without recursion. |
org.w3c.dom.Node |
getLastChild()
The last child of this node.
|
java.lang.String |
getLocalName()
Returns the local part of the qualified name of this node.
|
java.lang.String |
getNamespaceURI()
The namespace URI of this node, or
null if it is
unspecified. |
org.w3c.dom.Node |
getNextSibling()
The node immediately following this node.
|
org.w3c.dom.Node |
getNode()
Retrieves the encapsulated node.
|
XmlNodeFactory<? extends XmlNode> |
getNodeFactory()
Retrieves the factory to create node lists.
|
java.lang.String |
getNodeName()
The name of this node, depending on its type; see the table above.
|
short |
getNodeType()
A code representing the type of the underlying object, as defined above.
|
java.lang.String |
getNodeValue()
The value of this node, depending on its type; see the table above.
|
org.w3c.dom.Document |
getOwnerDocument()
The
Document object associated with this node. |
<T extends XmlDocument> |
getOwnerXmlDocument(java.lang.Class<T> documentClass)
Retrieves the
XmlDocument containing this node. |
org.w3c.dom.Node |
getParentNode()
The parent of this node.
|
java.lang.String |
getPrefix()
The namespace prefix of this node, or
null if it is
unspecified. |
org.w3c.dom.Node |
getPreviousSibling()
The node immediately preceding this node.
|
java.lang.String |
getTextContent()
This attribute returns the text content of this node and its descendants.
|
java.lang.Object |
getUserData(java.lang.String key)
Retrieves the object associated to a key on a this node.
|
boolean |
hasAttribute(java.lang.String attribute)
Checks, if the attribute with the given name is present.
|
boolean |
hasAttributes()
Returns whether this node (if it is an element) has any attributes.
|
boolean |
hasChildNodes()
Returns whether this node has any children.
|
int |
hashCode() |
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
Inserts the node
newChild before the existing child node
refChild. |
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
This method checks if the specified
namespaceURI is the
default namespace or not. |
boolean |
isEqualNode(org.w3c.dom.Node other)
Tests whether two nodes are equal.
|
boolean |
isSameNode(org.w3c.dom.Node other)
Returns whether this node is the same node as the given one.
|
boolean |
isSupported(java.lang.String feature,
java.lang.String version)
Tests whether the DOM implementation implements a specific feature and
that feature is supported by this node.
|
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
Look up the namespace URI associated to the given prefix, starting from
this node.
|
java.lang.String |
lookupPrefix(java.lang.String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from
this node.
|
void |
normalize()
Puts all
Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments, processing
instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. |
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node oldChild)
Removes the child node indicated by
oldChild from the list
of children, and returns it. |
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
Replaces the child node
oldChild with
newChild in the list of children, and returns the
oldChild node. |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Convenient method to set the value of an attribute.
|
void |
setNodeValue(java.lang.String nodeValue)
The value of this node, depending on its type; see the table above.
|
void |
setPrefix(java.lang.String prefix)
The namespace prefix of this node, or
null if it is
unspecified. |
void |
setTextContent(java.lang.String textContent)
This attribute returns the text content of this node and its descendants.
|
java.lang.Object |
setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
Associate an object to a key on this node.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTagName, newInstanceprotected AbstractXmlNode(org.w3c.dom.Node n,
XmlNodeFactory<? extends XmlNode> nodeFactory)
n - The encapsulated node.nodeFactory - Node factory to create node lists.public final org.w3c.dom.NodeList getChildNodes()
NodeList that contains all children of this node.getChildNodes in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node getNode()
public final XmlNodeFactory<? extends XmlNode> getNodeFactory()
public final java.lang.String getAttribute(java.lang.String attribute)
getAttribute in interface XmlNodeattribute - Name of the attribute.null if the value of the
attribute cannot be retrieved.public final boolean hasAttribute(java.lang.String attribute)
attribute - name of the attribute to check fortrue if there is an attribute with the given namepublic final void setAttribute(java.lang.String name,
java.lang.String value)
null then the attribute is removed.setAttribute in interface XmlNodename - Name of the attribute.value - New value of the attribute or null to remove the
attribute.public final org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
newChild to the end of the list of children
of this node.appendChild in interface org.w3c.dom.NodenewChild - The node to add.If it is a DocumentFragment object,
the entire contents of the document fragment are moved into the
child list of this nodepublic AbstractXmlNode appendDeepClone(AbstractXmlNode origin)
origin - the node to clonepublic final org.w3c.dom.Node cloneNode(boolean deep)
cloneNode in interface org.w3c.dom.Nodedeep - If true, recursively clone the subtree under the
specified node; if false, clone only the node
itself (and its attributes, if it is an Element).public final org.w3c.dom.NamedNodeMap getAttributes()
NamedNodeMap containing the attributes of this node (if
it is an Element) or null otherwise.getAttributes in interface org.w3c.dom.Nodepublic final java.lang.String getLocalName()
getLocalName in interface org.w3c.dom.Nodepublic final java.lang.String getNamespaceURI()
null if it is
unspecified.getNamespaceURI in interface org.w3c.dom.Nodepublic final java.lang.String getNodeName()
getNodeName in interface org.w3c.dom.Nodepublic final short getNodeType()
getNodeType in interface org.w3c.dom.Nodepublic final java.lang.String getNodeValue()
getNodeValue in interface org.w3c.dom.Nodepublic final org.w3c.dom.Document getOwnerDocument()
Document object associated with this node.getOwnerDocument in interface org.w3c.dom.Nodepublic final <T extends XmlDocument> T getOwnerXmlDocument(java.lang.Class<T> documentClass)
XmlDocument containing this node.T - type of the owner document.documentClass - owner document's class.public final java.lang.String getPrefix()
null if it is
unspecified.getPrefix in interface org.w3c.dom.Nodepublic final java.lang.Object getUserData(java.lang.String key)
getUserData in interface org.w3c.dom.Nodekey - The key the object is associated to.null if there was none.public final boolean hasAttributes()
hasAttributes in interface org.w3c.dom.Nodetrue if this node has any attributes,
false otherwise.public final boolean hasChildNodes()
hasChildNodes in interface org.w3c.dom.Nodetrue if this node has any children,
false otherwise.public final org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
newChild before the existing child node
refChild.insertBefore in interface org.w3c.dom.NodenewChild - The node to insert.refChild - The reference node, i.e., the node before which the new node must
be inserted.public final boolean isSupported(java.lang.String feature,
java.lang.String version)
isSupported in interface org.w3c.dom.Nodefeature - The name of the feature to test. This is the same name which can
be passed to the method hasFeature on
DOMImplementation.version - This is the version number of the feature to test. In Level 2,
version 1, this is the string "2.0". If the version is not
specified, supporting any version of the feature will cause the
method to return true.true if the specified feature is supported
on this node, false otherwise.public final void normalize()
Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments, processing
instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes.normalize in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
oldChild from the list
of children, and returns it.removeChild in interface org.w3c.dom.NodeoldChild - The node being removed.public final org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
oldChild with
newChild in the list of children, and returns the
oldChild node.replaceChild in interface org.w3c.dom.NodenewChild - The new node to put in the child list.oldChild - The node being replaced in the list.public final void setNodeValue(java.lang.String nodeValue)
setNodeValue in interface org.w3c.dom.NodenodeValue - Stringpublic final void setPrefix(java.lang.String prefix)
null if it is
unspecified.setPrefix in interface org.w3c.dom.Nodeprefix - Stringpublic final java.lang.Object setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
setUserData in interface org.w3c.dom.Nodekey - The key to associate the object to.data - The object to associate to the given key, or null
to remove any existing association to that key.handler - The handler to associate to that key, or nullDOMUserData previously associated to
the given key on this node, or null if there was
none.public final org.w3c.dom.Node getFirstChild()
getFirstChild in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node getLastChild()
getLastChild in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node getNextSibling()
getNextSibling in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node getPreviousSibling()
getPreviousSibling in interface org.w3c.dom.Nodepublic final org.w3c.dom.Node getParentNode()
getParentNode in interface org.w3c.dom.Nodepublic final java.lang.String getBaseURI()
null if the
implementation wasn't able to obtain an absolute URI.getBaseURI in interface org.w3c.dom.Nodepublic final short compareDocumentPosition(org.w3c.dom.Node other)
compareDocumentPosition in interface org.w3c.dom.Nodeother - The node to compare against the reference node.public final java.lang.String getTextContent()
getTextContent in interface org.w3c.dom.Nodepublic final java.lang.String getFirstLevelTextContent()
getTextContent() but without recursion.public final void setTextContent(java.lang.String textContent)
setTextContent in interface org.w3c.dom.NodetextContent - Stringpublic final boolean isSameNode(org.w3c.dom.Node other)
isSameNode in interface org.w3c.dom.Nodeother - The node to test against.true if the nodes are the same,
false otherwise.public final java.lang.String lookupPrefix(java.lang.String namespaceURI)
lookupPrefix in interface org.w3c.dom.NodenamespaceURI - The namespace URI to look for.null if none is found. If more than one prefix are
associated to the namespace prefix, the returned namespace prefix
is implementation dependent.public final boolean isDefaultNamespace(java.lang.String namespaceURI)
namespaceURI is the
default namespace or not.isDefaultNamespace in interface org.w3c.dom.NodenamespaceURI - The namespace URI to look for.true if the specified
namespaceURI is the default namespace,
false otherwise.public final java.lang.String lookupNamespaceURI(java.lang.String prefix)
lookupNamespaceURI in interface org.w3c.dom.Nodeprefix - The prefix to look for. If this parameter is null,
the method will return the default namespace URI if any.null if
none is found.public final boolean isEqualNode(org.w3c.dom.Node other)
isEqualNode in interface org.w3c.dom.Nodeother - The node to compare equality with.true if the nodes are equal,
false otherwise.public final java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
getFeature in interface org.w3c.dom.Nodefeature - The name of the feature requested. Note that any plus sign "+"
prepended to the name of the feature will be ignored since it is
not significant in the context of this method.version - This is the version number of the feature to test.null if
there is no object which implements interfaces associated with
that feature. If the DOMObject returned by this
method implements the Node interface, it must
delegate to the primary core Node and not return
results inconsistent with the primary core Node
such as attributes, childNodes, etc.public final <T extends XmlNode> T addChild(java.lang.Class<T> tagClass)
T - Node type to load.tagClass - The class type of the node to add.public final <T extends XmlNode> T appendChild(java.lang.Class<T> tagClass)
T - Node type to load.tagClass - The class type of the node to add.public final XmlNode addChild(java.lang.String tagName)
public final <T extends XmlNode> java.util.Collection<T> getChildNodes(java.lang.Class<T> tagClass)
getChildNodes in interface XmlNodeT - Type of the child nodes.tagClass - Class of child node to return.public final <T extends XmlNode> java.util.Collection<T> getChildren()
getChildren in interface XmlNodeT - Type of the child nodes.protected abstract boolean canContainChild(java.lang.String childName)
childName - Name of child.public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Collection<java.lang.String> getAttributeNames()
getAttributeNames in interface XmlNodepublic final java.util.Collection<java.lang.String> getDefinedAttributeNames()
public final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.Object