org.exolab.adaptx.xpath
Class NodeSet
- java.io.Serializable
public final class NodeSet
Represents a node-set. A node-set is used as the result of an XPath
expression, and during the expression to keep track of nodes being
evaluated. As such, it is a mutable object. Care must be taken, as
a node-set is not thread-safe and must not be used by two XPath
expressions evaluating concurrently.
$Revision: 1.2 $ $Date: 2003/05/13 08:01:12 $
NodeSet() - Constructs a new empty node-set.
|
NodeSet(int size) - Constructs a new empty node-set with the specified size.
|
NodeSet(XPathNode node) - Constructs a new node-set with the specified node.
|
void | add(NodeSet nodeSet) - Adds all nodes from the specified node-set to this node-set
without duplication.
|
void | add(NodeSet nodeSet, boolean ignoreDuplicates) - Adds all nodes from the specified node-set to this node-set.
|
boolean | add(XPathNode node) - Adds the specified node to this node-set without duplication.
|
boolean | add(XPathNode node, boolean ignoreDuplicates) - Adds the specified node to this node-set.
|
boolean | booleanValue() - Returns the result as a boolean value.
|
void | clear() - Removes all elements from this node-set.
|
boolean | contains(XPathNode node) - Returns true if the specified node is contained in this node-set.
|
boolean | equals(XPathResult result) - Returns true if the given result is a node-set result
and has the same set of nodes.
|
int | getResultType() - Returns the type of this result.
|
int | indexOf(XPathNode node) - Returns the position of the specified node in this node-set.
|
XPathNode | item(int index) - Returns the node at the specified index.
|
Object | javaObject() - Returns the result as a Java object.
|
double | numberValue() - Returns the result as a number value.
|
void | remove(int index) - Removes the specified node from the node-set.
|
boolean | remove(XPathNode node) - Removes the specified node from the node-set.
|
int | size() - Returns the number of nodes in the node-set.
|
String | stringValue() - Returns the result as a string value.
|
XPathNode[] | toArray() - Returns an array containing all the nodes in this node-set.
|
String | toString() - Returns the string representation of this NodeSet.
|
NodeSet
public NodeSet()
Constructs a new empty node-set.
NodeSet
public NodeSet(int size)
Constructs a new empty node-set with the specified size.
This constructor is used if the node-set is known to hold
only the specified number of nodes.
size
- The expected node-set size
NodeSet
public NodeSet(XPathNode node)
Constructs a new node-set with the specified node.
node
- The node to include in the node-set
add
public void add(NodeSet nodeSet)
Adds all nodes from the specified node-set to this node-set
without duplication.
nodeSet
- The node-set from which to add nodes
add
public void add(NodeSet nodeSet,
boolean ignoreDuplicates)
Adds all nodes from the specified node-set to this node-set.
This method allows control over whether or not to perform
duplicate checking.
nodeSet
- The node-set from which to add nodesignoreDuplicates
- If true, do not perform duplicate checking *
add
public boolean add(XPathNode node)
Adds the specified node to this node-set without duplication.
node
- The node to add to this node-set
- True if the node was added, false if the node was already
in this node-set
add
public boolean add(XPathNode node,
boolean ignoreDuplicates)
Adds the specified node to this node-set. This method allows
control over whether or not to perform duplicate checking.
node
- The node to add to this node-setignoreDuplicates
- If true, do not perform duplicate checking
- True if the node was added, false if the node was already
in this node-set
booleanValue
public boolean booleanValue()
Returns the result as a boolean value. Returns true if the
node-set is not empty.
- booleanValue in interface XPathResult
- The result as a boolean value
clear
public void clear()
Removes all elements from this node-set.
contains
public boolean contains(XPathNode node)
Returns true if the specified node is contained in this node-set.
node
- The specified node to search
- True if the specified node is contained in this node-set
equals
public boolean equals(XPathResult result)
Returns true if the given result is a node-set result
and has the same set of nodes.
- equals in interface XPathResult
- True if a node-set result and has same set of nodes
indexOf
public int indexOf(XPathNode node)
Returns the position of the specified node in this node-set.
Returns -1 i the node is not included in this node-set.
The node's index is based on the order in which it was
added to the node-set, minus any nodes of lower index position
that were removed from the node-set. The index ranges between
zero and
size() - 1 (inclusive).
node
- the Node to get the index for
item
public XPathNode item(int index)
Returns the node at the specified index. Throws
IndexOutOfBoundsException
is the index is out of range.
The index is as returned by
indexOf(XPathNode)
.
index
- The position of the node to return
javaObject
public Object javaObject()
Returns the result as a Java object. Returns an object of
type
NodeSet
representing this node-set.
- javaObject in interface XPathResult
- The result as a Java object
numberValue
public double numberValue()
Returns the result as a number value. Returns the number value of
the node's string value, or java.lang.Double.NaN
if the
node-set is empty.
- numberValue in interface XPathResult
- The result as a number value
remove
public void remove(int index)
Removes the specified node from the node-set. The node is
identified by position. Throws
IndexOutOfBoundsException
is the index is out of range. The index is as returned by
indexOf(XPathNode)
.
index
- The position of the node to remove
remove
public boolean remove(XPathNode node)
Removes the specified node from the node-set. Returns true
if the node was found and removed, false if the node was
not included in this node-set.
node
- The node to remove from this node-set
- True if the node was removed
size
public int size()
Returns the number of nodes in the node-set.
- The number of nodes in the node-set
stringValue
public String stringValue()
Returns the result as a string value. Returns the string value of the
node that is first in document order, or the empty string if the node-set
is empty.
Note: currently returns the string value of the first node in
the node-set.
- stringValue in interface XPathResult
- The result as a string value
toArray
public XPathNode[] toArray()
Returns an array containing all the nodes in this node-set.
Returns an empty array if the node-set is empty.
- An array containing all the nodes in this node-set
toString
public String toString()
Returns the string representation of this NodeSet. This
will be the concatenation of the string values of
all the nodes contained within this NodeSet
- the string representation of this NodeSet.