|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dom4j.tree.AbstractNode
AbstractNode
is an abstract base class for tree implementors
to use for implementation inheritence.
Field Summary | |
protected static java.lang.String[] |
NODE_TYPE_NAMES
|
Fields inherited from interface org.dom4j.Node |
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE |
Constructor Summary | |
AbstractNode()
|
Method Summary | |
org.w3c.dom.Node |
adoptNode(org.w3c.dom.Node source)
|
Node |
asXPathResult(Element parent)
asXPathResult returns a version of this node which is
capable of being an XPath result. |
java.lang.Object |
clone()
clone will return a deep clone or if this node is
read-only then clone will return the same instance. |
short |
compareDocumentPosition(org.w3c.dom.Node other)
|
Pattern |
createPattern(java.lang.String patternText)
|
XPath |
createXPath(java.lang.String xpathExpression)
createXPath creates an XPath object for the given
xpathExpression. |
NodeFilter |
createXPathFilter(java.lang.String patternText)
|
protected Node |
createXPathResult(Element parent)
|
Node |
detach()
Removes this node from its parent if there is one. |
java.lang.String |
getBaseURI()
DOM3 stubbed in for compilation! |
Document |
getDocument()
getDocument returns the Document that this
Node is part of if this node supports the parent
relationship. |
protected DocumentFactory |
getDocumentFactory()
|
java.lang.String |
getDocumentURI()
|
org.w3c.dom.DOMConfiguration |
getDomConfig()
|
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
|
java.lang.String |
getInputEncoding()
DOM3 Document interface stubs |
java.lang.String |
getName()
getName returns the name of this node. |
short |
getNodeType()
Returns the code according to the type of node. |
java.lang.String |
getNodeTypeName()
DOCUMENT ME! |
Element |
getParent()
getParent returns the parent Element if
this node supports the parent relationship or null if it is the root
element or does not support the parent relationship. |
java.lang.String |
getPath()
Returns the XPath expression which will return a node set containing the given node such as /a/b/@c. |
org.w3c.dom.TypeInfo |
getSchemaTypeInfo()
DOM3 Attr interface stubs |
boolean |
getStrictErrorChecking()
|
java.lang.String |
getStringValue()
Returns the XPath string-value of this node. |
java.lang.String |
getText()
Returns the text of this node. |
java.lang.String |
getTextContent()
|
java.lang.String |
getUniquePath()
Returns the XPath expression which will return a nodeset of one node which is the current node. |
java.lang.Object |
getUserData(java.lang.String key)
|
java.lang.String |
getWholeText()
|
java.lang.String |
getXmlEncoding()
|
boolean |
getXmlStandalone()
|
java.lang.String |
getXmlVersion()
|
boolean |
hasContent()
hasContent returns true if this node is a Branch (either
an Element or a Document) and it contains at least one content node such
as a child Element or Text node. |
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
|
boolean |
isElementContentWhitespace()
DOM3 Text interface stubs |
boolean |
isEqualNode(org.w3c.dom.Node arg)
|
boolean |
isId()
|
boolean |
isReadOnly()
isReadOnly returns true if this node is read only and
cannot be modified. |
boolean |
isSameNode(org.w3c.dom.Node other)
|
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
|
java.lang.String |
lookupPrefix(java.lang.String namespaceURI)
|
boolean |
matches(java.lang.String patternText)
matches returns true if evaluating the given XPath
expression on this node returns a non-empty node set containing this
node. |
void |
normalizeDocument()
|
java.lang.Number |
numberValueOf(java.lang.String xpathExpression)
numberValueOf evaluates an XPath expression and returns
the numeric value of the XPath expression if the XPath expression results
in a number, or null if the result is not a number. |
org.w3c.dom.Node |
renameNode(org.w3c.dom.Node n,
java.lang.String namespaceURI,
java.lang.String qualifiedName)
|
org.w3c.dom.Text |
replaceWholeText(java.lang.String content)
|
java.util.List |
selectNodes(java.lang.String xpathExpression)
selectNodes evaluates an XPath expression and returns the
result as a List of Node instances or
String instances depending on the XPath expression. |
java.util.List |
selectNodes(java.lang.String xpathExpression,
java.lang.String comparisonXPathExpression)
selectNodes evaluates an XPath expression then sorts the
results using a secondary XPath expression Returns a sorted
List of Node instances. |
java.util.List |
selectNodes(java.lang.String xpathExpression,
java.lang.String comparisonXPathExpression,
boolean removeDuplicates)
selectNodes evaluates an XPath expression then sorts the
results using a secondary XPath expression Returns a sorted
List of Node instances. |
java.lang.Object |
selectObject(java.lang.String xpathExpression)
selectObject evaluates an XPath expression and returns the
result as an Object . |
Node |
selectSingleNode(java.lang.String xpathExpression)
selectSingleNode evaluates an XPath expression and returns
the result as a single Node instance. |
void |
setDocument(Document document)
setDocument sets the document of this node if the parent
relationship is supported or does nothing if the parent relationship is
not supported. |
void |
setDocumentURI(java.lang.String documentURI)
|
void |
setIdAttribute(java.lang.String name,
boolean isId)
|
void |
setIdAttributeNode(org.w3c.dom.Attr idAttr,
boolean isId)
|
void |
setIdAttributeNS(java.lang.String namespaceURI,
java.lang.String localName,
boolean isId)
DOM3 Element interface stubs |
void |
setName(java.lang.String name)
Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only. |
void |
setParent(Element parent)
setParent sets the parent relationship of this node if the
parent relationship is supported or does nothing if the parent
relationship is not supported. |
void |
setStrictErrorChecking(boolean strictErrorChecking)
|
void |
setText(java.lang.String text)
Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only. |
void |
setTextContent(java.lang.String textContent)
|
java.lang.Object |
setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
|
void |
setXmlStandalone(boolean xmlStandalone)
|
void |
setXmlVersion(java.lang.String xmlVersion)
|
boolean |
supportsParent()
supportsParent returns true if this node supports the
parent relationship. |
java.lang.String |
valueOf(java.lang.String xpathExpression)
valueOf evaluates an XPath expression and returns the
textual representation of the results the XPath string-value of this
node. |
void |
write(java.io.Writer writer)
write writes this node as the default XML notation for
this node. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.dom4j.Node |
accept, asXML, getPath, getUniquePath |
Field Detail |
protected static final java.lang.String[] NODE_TYPE_NAMES
Constructor Detail |
public AbstractNode()
Method Detail |
public short getNodeType()
Node
getNodeType
in interface Node
public java.lang.String getNodeTypeName()
Node
getNodeTypeName
in interface Node
public Document getDocument()
Node
getDocument
returns the Document
that this
Node
is part of if this node supports the parent
relationship.
This method is an optional feature and may not be supported for all
Node
implementations.
getDocument
in interface Node
Document
public void setDocument(Document document)
Node
setDocument
sets the document of this node if the parent
relationship is supported or does nothing if the parent relationship is
not supported.
This method should only be called from inside a Document
implementation method and is not intended for general use.
setDocument
in interface Node
document
- is the new document of this node.public Element getParent()
Node
getParent
returns the parent Element
if
this node supports the parent relationship or null if it is the root
element or does not support the parent relationship.
This method is an optional feature and may not be supported for all
Node
implementations.
getParent
in interface Node
public void setParent(Element parent)
Node
setParent
sets the parent relationship of this node if the
parent relationship is supported or does nothing if the parent
relationship is not supported.
This method should only be called from inside an Element
implementation method and is not intended for general use.
setParent
in interface Node
parent
- is the new parent of this node.public boolean supportsParent()
Node
supportsParent
returns true if this node supports the
parent relationship.
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.
supportsParent
in interface Node
public boolean isReadOnly()
Node
isReadOnly
returns true if this node is read only and
cannot be modified. Any attempt to modify a read-only Node
will result in an UnsupportedOperationException
being
thrown.
isReadOnly
in interface Node
Node
is read only and cannot be
modified otherwise false.public boolean hasContent()
Node
hasContent
returns true if this node is a Branch (either
an Element or a Document) and it contains at least one content node such
as a child Element or Text node.
hasContent
in interface Node
Node
is a Branch with a nodeCount()
of one or more.public java.lang.String getPath()
Node
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
in interface Node
public java.lang.String getUniquePath()
Node
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
in interface Node
public java.lang.Object clone()
Node
clone
will return a deep clone or if this node is
read-only then clone will return the same instance.
clone
in interface Node
public Node detach()
Node
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() );
detach
in interface Node
public java.lang.String getName()
Node
getName
returns the name of this node. This is the XML
local name of the element, attribute, entity or processing instruction.
For CDATA and Text nodes this method will return null.
getName
in interface Node
public void setName(java.lang.String name)
Node
Sets the text data of this node or this method will throw an
UnsupportedOperationException
if it is read-only.
setName
in interface Node
name
- is the new name of this nodepublic java.lang.String getText()
Node
Returns the text of this node.
getText
in interface Node
public java.lang.String getStringValue()
Node
getStringValue
in interface Node
public void setText(java.lang.String text)
Node
Sets the text data of this node or this method will throw an
UnsupportedOperationException
if it is read-only.
setText
in interface Node
text
- is the new textual value of this nodepublic void write(java.io.Writer writer) throws java.io.IOException
Node
write
writes this node as the default XML notation for
this node. If you wish to control the XML output (such as for pretty
printing, changing the indentation policy etc.) then please use XMLWriter
or its derivations.
write
in interface Node
writer
- is the Writer
to output the XML to
java.io.IOException
- DOCUMENT ME!public java.lang.Object selectObject(java.lang.String xpathExpression)
Node
selectObject
evaluates an XPath expression and returns the
result as an Object
. The object returned can either be a List
of one or more Node
instances or a scalar object like a
String
or a Number
instance depending on the XPath
expression.
selectObject
in interface Node
xpathExpression
- is the XPath expression to be evaluated
List
of Node
instances, a String
or a Number
instance
depending on the XPath expression.public java.util.List selectNodes(java.lang.String xpathExpression)
Node
selectNodes
evaluates an XPath expression and returns the
result as a List
of Node
instances or
String
instances depending on the XPath expression.
selectNodes
in interface Node
xpathExpression
- is the XPath expression to be evaluated
Node
or String
instances depending on the XPath expressionpublic java.util.List selectNodes(java.lang.String xpathExpression, java.lang.String comparisonXPathExpression)
Node
selectNodes
evaluates an XPath expression then sorts the
results using a secondary XPath expression Returns a sorted
List
of Node
instances.
selectNodes
in interface Node
xpathExpression
- is the XPath expression to be evaluatedcomparisonXPathExpression
- is the XPath expression used to compare the results by for
sorting
Node
instances sorted by the
comparisonXPathExpressionpublic java.util.List selectNodes(java.lang.String xpathExpression, java.lang.String comparisonXPathExpression, boolean removeDuplicates)
Node
selectNodes
evaluates an XPath expression then sorts the
results using a secondary XPath expression Returns a sorted
List
of Node
instances.
selectNodes
in interface Node
xpathExpression
- is the XPath expression to be evaluatedcomparisonXPathExpression
- is the XPath expression used to compare the results by for
sortingremoveDuplicates
- if this parameter is true then duplicate values (using the
comparisonXPathExpression) are removed from the result List.
Node
instances sorted by the
comparisonXPathExpressionpublic Node selectSingleNode(java.lang.String xpathExpression)
Node
selectSingleNode
evaluates an XPath expression and returns
the result as a single Node
instance.
selectSingleNode
in interface Node
xpathExpression
- is the XPath expression to be evaluated
Node
matching the XPath expressionpublic java.lang.String valueOf(java.lang.String xpathExpression)
Node
valueOf
evaluates an XPath expression and returns the
textual representation of the results the XPath string-value of this
node. The string-value for a given node type is defined in the XPath specification .
valueOf
in interface Node
xpathExpression
- is the XPath expression to be evaluated
public java.lang.Number numberValueOf(java.lang.String xpathExpression)
Node
numberValueOf
evaluates an XPath expression and returns
the numeric value of the XPath expression if the XPath expression results
in a number, or null if the result is not a number.
numberValueOf
in interface Node
xpathExpression
- is the XPath expression to be evaluated
public boolean matches(java.lang.String patternText)
Node
matches
returns true if evaluating the given XPath
expression on this node returns a non-empty node set containing this
node.
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 )
matches
in interface Node
patternText
- is an XPath expression
public XPath createXPath(java.lang.String xpathExpression)
Node
createXPath
creates an XPath object for the given
xpathExpression. The XPath object allows the variable context to be
specified.
createXPath
in interface Node
xpathExpression
- is the XPath expression to be evaluated
public NodeFilter createXPathFilter(java.lang.String patternText)
public Pattern createPattern(java.lang.String patternText)
public Node asXPathResult(Element parent)
Node
asXPathResult
returns a version of this node which is
capable of being an XPath result. The result of an XPath expression
should always support the parent relationship, whether the original XML
tree was singly or doubly linked. If the node does not support the parent
relationship then a new node will be created which is linked to its
parent and returned.
asXPathResult
in interface Node
parent
- DOCUMENT ME!
Node
which supports the parent relationshipprotected DocumentFactory getDocumentFactory()
protected Node createXPathResult(Element parent)
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
public boolean isId()
public void setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)
public void setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public void setIdAttribute(java.lang.String name, boolean isId) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public boolean isElementContentWhitespace()
public java.lang.String getWholeText()
public org.w3c.dom.Text replaceWholeText(java.lang.String content)
public java.lang.String getBaseURI()
public short compareDocumentPosition(org.w3c.dom.Node other) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public java.lang.String getTextContent() throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public void setTextContent(java.lang.String textContent) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public boolean isSameNode(org.w3c.dom.Node other)
public java.lang.String lookupPrefix(java.lang.String namespaceURI)
public boolean isDefaultNamespace(java.lang.String namespaceURI)
public java.lang.String lookupNamespaceURI(java.lang.String prefix)
public boolean isEqualNode(org.w3c.dom.Node arg)
public java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
public java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
public java.lang.Object getUserData(java.lang.String key)
public java.lang.String getInputEncoding()
public java.lang.String getXmlEncoding()
public boolean getXmlStandalone()
public void setXmlStandalone(boolean xmlStandalone) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public java.lang.String getXmlVersion()
public void setXmlVersion(java.lang.String xmlVersion) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public boolean getStrictErrorChecking()
public void setStrictErrorChecking(boolean strictErrorChecking)
public java.lang.String getDocumentURI()
public void setDocumentURI(java.lang.String documentURI)
public org.w3c.dom.DOMConfiguration getDomConfig()
public void normalizeDocument()
public org.w3c.dom.Node renameNode(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws org.w3c.dom.DOMException
org.w3c.dom.DOMException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |