public final class Token extends Object implements XNode
XNode.Type
Modifier and Type | Method and Description |
---|---|
Iterator<XNode> |
attributes()
Returns iterator over the attributes contained in this element
node.
|
String |
attributeValue(Name name)
Returns the value of attribute having specified name contained in this
element node.
|
int |
compareTo(XNode other)
Compares this node with specified object which must be an XNode too.
|
String |
data()
Returns the value of this attribute node or the text contained in this
text, comment or processing-instruction node.
|
XNode |
deepCopy()
Returns a deep copy of this node.
|
XNode |
document()
Returns the document containing this node.
|
boolean |
equals(Object other)
Tests if this node is equivalent to specified object.
|
XNode |
firstChild()
Returns the first child node of this element or document node.
|
XNode |
following()
Returns the node following this node.
|
URL |
getBaseURL()
Returns the URL which can be used to resolve URLs which are relative to
this node.
|
String |
getLabel()
Returns a string which represents this XNode.
|
URL |
getSourceURL()
Returns the URL of the file from which this XNode has been loaded.
|
XNode |
lastChild()
Returns the last child node of this element or document node.
|
Name |
name()
Returns the name of this element node, the name of this attribute node
or the target of this processing-instruction node.
|
NamespacePrefixMap |
namespacePrefixMap()
Returns the NamespacePrefixMap which can be used to map prefixes to
namespaces and namespaces to prefixes in the context of this node.
|
XNode |
parent()
Returns the parent of the node.
|
XNode |
preceding()
Returns the node preceding this node.
|
String |
toString() |
XNode.Type |
type()
Returns the type of this node.
|
public Token(String text, XNode document) throws EvalException
EvalException
public XNode.Type type()
XNode
public XNode document()
XNode
public XNode parent()
XNode
null
.public XNode following()
XNode
null
for an
attribute or a document node.public XNode preceding()
XNode
null
for an
attribute or a document node.public Name name()
XNode
null
for all other types of nodes.
The target of a processing-instruction has no namespace.
public String data()
XNode
null
for all other types of nodes.public NamespacePrefixMap namespacePrefixMap()
XNode
namespacePrefixMap
in interface XNode
public XNode firstChild()
XNode
null
for all other types of nodes.firstChild
in interface XNode
public XNode lastChild()
XNode
null
for all other types of nodes.public String attributeValue(Name name)
XNode
null
if this node is not an element
node.attributeValue
in interface XNode
public Iterator<XNode> attributes()
XNode
null
if this node is not an element node.
This iterator does not support the remove
method.
attributes
in interface XNode
public boolean equals(Object other)
XNode
==
because attribute nodes
are synthesized when needed to (that is, they are not real nodes).public int compareTo(XNode other)
XNode
Document order has no meaning for attribute nodes contained in the same element. Attribute nodes contained in the same element are compared by their names.
The two nodes may belong to two different documents. In such case, the two documents are compared by their URLs.
compareTo
in interface XNode
compareTo
in interface Comparable<XNode>
public XNode deepCopy()
XNode
public URL getSourceURL()
XNode
null
if such URL is unknown.
This URL is mainly useful in error messages or in a GUI.
If you need to resolve URLs which are relative to this node,
use XNode.getBaseURL()
instead.
getSourceURL
in interface XNode
public URL getBaseURL()
XNode
null
if such URL is unknown.
This URL is often the same as the one returned by
XNode.getSourceURL()
, but not always. Example:
<root> <list xml:base="file:///home/john/"> <item/><item/><item/> </list> </root>If the SourceURL of element root is "file:///tmp/doc.xml", then the SourceURL of element list is also "file:///tmp/doc.xml", but the BaseURL of this element is "file:///home/john/".
getBaseURL
in interface XNode
public String getLabel()
XNode