Node defines the polymorphic behavior for all XML nodes in a
dom4j tree.
A node can be output as its XML format, can be detached from its position in
a document and can have XPath expressions evaluated on itself.
A node may optionally support the parent relationship and may be read only.
supportsParent, isReadOnly
| Modifier and Type | Field and Description |
|---|---|
| public static final short | ANY_NODE
Matches Element nodes |
| public static final short | ATTRIBUTE_NODE
Matches elements nodes |
| public static final short | CDATA_SECTION_NODE
Matches elements nodes |
| public static final short | COMMENT_NODE
Matches Comments nodes |
| public static final short | DOCUMENT_NODE
Matches Document nodes |
| public static final short | DOCUMENT_TYPE_NODE
Matches DocumentType nodes |
| public static final short | ELEMENT_NODE
Matches Element nodes |
| public static final short | ENTITY_REFERENCE_NODE
Matches elements nodes |
| public static final short | MAX_NODE_TYPE
The maximum number of node types for sizing purposes |
| public static final short | NAMESPACE_NODE
Matchs a Namespace Node - NOTE this differs from DOM |
| public static final short | PROCESSING_INSTRUCTION_NODE
Matches ProcessingInstruction |
| public static final short | TEXT_NODE
Matches elements nodes |
| public static final short | UNKNOWN_NODE
Does not match any valid node |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public String | Returns: the XML representation of this node
|
| public Node | Returns: aNode which supports the parent relationshipDOCUMENT ME! parent)
|
| public Object | Returns: a deep clone of myself or myself if I am read only.
|
| public XPath | Returns: an XPath object represeting the given expressionis the XPath expression to be evaluated xpathExpression)
|
| public Node | Returns: the node that has been removed from its parent node if any and its document if any.Removes this node from its parent if there is one. |
| public Document | Returns: the document of this node or null if this feature is not supported or the node is not associated with aDocument
|
| public String | |
| public short | Returns: a W3C DOM complient code for the node type such as ELEMENT_NODE or ATTRIBUTE_NODEReturns the code according to the type of node. |
| public String | Returns: the name of the type of node such as "Document", "Element", "Attribute" or "Text"DOCUMENT ME! |
| public Element | Returns: the parent of this node or null if it is the root of the tree or the parent relationship is not supported.
|
| public String | Returns: the XPath expression which will return a nodeset containing at least this node.Returns the XPath expression which will return a node set containing the given node such as /a/b/@c. |
| public String | Returns: the XPath expression relative to the given context which will return a nodeset containing at least this node.is the parent context from which the relative path should
start. If the context is null or the context is not an
ancestor of this node then the path will be absolute and start
from the document and so begin with the '/' character. context)Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c. |
| public String | Returns: the text from all the child Text and Element nodes appended together.Returns the XPath string-value of this node. |
| public String | |
| public String | Returns: the XPath expression which will return a nodeset containing just this node.Returns the XPath expression which will return a nodeset of one node which is the current node. |
| public String | Returns: the XPath expression relative to the given context which will return a nodeset containing just this node.is the parent context from which the path should start. If the
context is null or the context is not an ancestor of this node
then the path will start from the document and so begin with
the '/' character. context)Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node. |
| public boolean | Returns: true if thisNode is a Branch with a nodeCount()
of one or more.
|
| public boolean | Returns: true if thisNode is read only and cannot be
modified otherwise false.
|
| public boolean | |
| public Number | Returns: the numeric result of the XPath expression or null if the result is not a number.is the XPath expression to be evaluated xpathExpression)
|
| public List | Returns: the list ofNode or String
instances depending on the XPath expressionis the XPath expression to be evaluated xpathExpression)
|
| public List | Returns: the list ofNode instances sorted by the
comparisonXPathExpressionis the XPath expression to be evaluated xpathExpression, String is the XPath expression used to compare the results by for
sorting comparisonXPathExpression)
|
| public List | Returns: the list ofNode instances sorted by the
comparisonXPathExpressionis the XPath expression to be evaluated xpathExpression, String is the XPath expression used to compare the results by for
sorting comparisonXPathExpression, boolean if this parameter is true then duplicate values (using the
comparisonXPathExpression) are removed from the result List. removeDuplicates)
|
| public Object | |
| public Node | Returns: theNode matching the XPath expressionis the XPath expression to be evaluated xpathExpression)
|
| public void | setDocument(Document
is the new document of this node. document)
|
| public void | |
| public void | |
| public void | |
| public boolean | Returns: true if this node supports the parent relationship or false it is not supported
|
| public String | |
| public void |
| ANY_NODE | back to summary |
|---|---|
| public static final short ANY_NODE Matches Element nodes | |
| ATTRIBUTE_NODE | back to summary |
|---|---|
| public static final short ATTRIBUTE_NODE Matches elements nodes | |
| CDATA_SECTION_NODE | back to summary |
|---|---|
| public static final short CDATA_SECTION_NODE Matches elements nodes | |
| COMMENT_NODE | back to summary |
|---|---|
| public static final short COMMENT_NODE Matches Comments nodes | |
| DOCUMENT_NODE | back to summary |
|---|---|
| public static final short DOCUMENT_NODE Matches Document nodes | |
| DOCUMENT_TYPE_NODE | back to summary |
|---|---|
| public static final short DOCUMENT_TYPE_NODE Matches DocumentType nodes | |
| ELEMENT_NODE | back to summary |
|---|---|
| public static final short ELEMENT_NODE Matches Element nodes | |
| ENTITY_REFERENCE_NODE | back to summary |
|---|---|
| public static final short ENTITY_REFERENCE_NODE Matches elements nodes | |
| MAX_NODE_TYPE | back to summary |
|---|---|
| public static final short MAX_NODE_TYPE The maximum number of node types for sizing purposes | |
| NAMESPACE_NODE | back to summary |
|---|---|
| public static final short NAMESPACE_NODE Matchs a Namespace Node - NOTE this differs from DOM | |
| PROCESSING_INSTRUCTION_NODE | back to summary |
|---|---|
| public static final short PROCESSING_INSTRUCTION_NODE Matches ProcessingInstruction | |
| TEXT_NODE | back to summary |
|---|---|
| public static final short TEXT_NODE Matches elements nodes | |
| UNKNOWN_NODE | back to summary |
|---|---|
| public static final short UNKNOWN_NODE Does not match any valid node | |
| accept | back to summary |
|---|---|
| public void accept(Visitor visitor)
| |
| asXML | back to summary |
|---|---|
| public String asXML()
| |
| asXPathResult | back to summary |
|---|---|
| public Node asXPathResult(Element parent)
| |
| clone | back to summary |
|---|---|
| public Object clone()
| |
| createXPath | back to summary |
|---|---|
| public XPath createXPath(String xpathExpression) throws InvalidXPathException
| |
| detach | back to summary |
|---|---|
| public Node detach() Removes this node from its parent if there is one. If this node is the root element of a document then it is removed from the document as well. This method is useful if you want to remove a node from its source document and add it to another document. For example Node node = ...; Element someOtherElement = ...;
someOtherElement.add( node.detach() );
| |
| getDocument | back to summary |
|---|---|
| public Document getDocument()
This method is an optional feature and may not be supported for all
| |
| getName | back to summary |
|---|---|
| public String getName()
| |
| getNodeType | back to summary |
|---|---|
| public short getNodeType() Returns the code according to the type of node. This makes processing nodes polymorphically much easier as the switch statement can be used instead of multiple if (instanceof) statements.
| |
| getNodeTypeName | back to summary |
|---|---|
| public String getNodeTypeName() DOCUMENT ME!
| |
| getParent | back to summary |
|---|---|
| public Element getParent()
This method is an optional feature and may not be supported for all
| |
| getPath | back to summary |
|---|---|
| public String getPath() Returns the XPath expression which will return a node set containing the given node such as /a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.
| |
| getPath | back to summary |
|---|---|
| public String getPath(Element context) Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.
| |
| getStringValue | back to summary |
|---|---|
| public String getStringValue() Returns the XPath string-value of this node. The behaviour of this method is defined in the XPath specification .
| |
| getText | back to summary |
|---|---|
| public String getText() Returns the text of this node.
| |
| getUniquePath | back to summary |
|---|---|
| public String getUniquePath() Returns the XPath expression which will return a nodeset of one node which is the current node. This method will use the XPath index operator to restrict the path if multiple elements with the same name occur on the path.
| |
| getUniquePath | back to summary |
|---|---|
| public String getUniquePath(Element context) Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node. This method will use the XPath index operator to restrict the path if multiple elements with the same name occur on the path.
| |
| hasContent | back to summary |
|---|---|
| public boolean hasContent()
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly()
| |
| matches | back to summary |
|---|---|
| public boolean matches(String xpathExpression)
This method does not behave like the <xsl:if> element - if you want that behaviour, to evaluate if an XPath expression matches something, then you can use the following code to be equivalent... if ( node.selectSingleNode( "/some/path" ) != nulll )
| |
| numberValueOf | back to summary |
|---|---|
| public Number numberValueOf(String xpathExpression)
| |
| selectNodes | back to summary |
|---|---|
| public List
| |
| selectNodes | back to summary |
|---|---|
| public List
| |
| selectNodes | back to summary |
|---|---|
| public List
| |
| selectObject | back to summary |
|---|---|
| public Object selectObject(String xpathExpression)
| |
| selectSingleNode | back to summary |
|---|---|
| public Node selectSingleNode(String xpathExpression)
| |
| setDocument | back to summary |
|---|---|
| public void setDocument(Document document)
This method should only be called from inside a
| |
| setName | back to summary |
|---|---|
| public void setName(String name)
Sets the text data of this node or this method will throw an
| |
| setParent | back to summary |
|---|---|
| public void setParent(Element parent)
This method should only be called from inside an
| |
| setText | back to summary |
|---|---|
| public void setText(String text)
Sets the text data of this node or this method will throw an
| |
| supportsParent | back to summary |
|---|---|
| public boolean supportsParent()
Some XML tree implementations are singly linked and only support downward navigation through children relationships. The default case is that both parent and children relationships are supported though for memory and performance reasons the parent relationship may not be supported.
| |
| valueOf | back to summary |
|---|---|
| public String valueOf(String xpathExpression)
| |
| write | back to summary |
|---|---|
| public void write(Writer writer) throws IOException
| |