public class NodeSetDTM extends NodeVector implements DTMIterator, java.lang.Cloneable
The NodeSetDTM class can act as either a NodeVector, NodeList, or NodeIterator. However, in order for it to act as a NodeVector or NodeList, it's required that setShouldCacheNodes(true) be called before the first nextNode() is called, in order that nodes can be added as they are fetched. Derived classes that implement iterators must override runTo(int index), in order that they may run the iteration to the given index.
Note that we directly implement the DOM's NodeIterator interface. We do not emulate all the behavior of the standard NodeIterator. In particular, we do not guarantee to present a "live view" of the document ... but in XSLT, the source document should never be mutated, so this should never be an issue.
Thought: Should NodeSetDTM really implement NodeList and NodeIterator, or should there be specific subclasses of it which do so? The advantage of doing it all here is that all NodeSetDTMs will respond to the same calls; the disadvantage is that some of them may return less-than-enlightening results when you do so.
FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP| Constructor and Description |
|---|
NodeSetDTM(DTMIterator ni)
Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
|
NodeSetDTM(DTMManager dtmManager)
Create an empty nodelist.
|
NodeSetDTM(int node,
DTMManager dtmManager)
Create a NodeSetDTM which contains the given Node.
|
NodeSetDTM(int blocksize,
int dummy,
DTMManager dtmManager)
Create an empty, using the given block size.
|
NodeSetDTM(NodeIterator iterator,
XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
|
NodeSetDTM(NodeList nodeList,
XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
|
NodeSetDTM(NodeSetDTM nodelist)
Create a NodeSetDTM, and copy the members of the
given NodeSetDTM into it.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addElement(int value)
Append a Node onto the vector.
|
void |
addNode(int n)
Add a node to the NodeSetDTM.
|
int |
addNodeInDocOrder(int node,
boolean test,
XPathContext support)
Add the node into a vector of nodes where it should occur in
document order.
|
int |
addNodeInDocOrder(int node,
XPathContext support)
Add the node into a vector of nodes where it should occur in
document order.
|
void |
addNodes(DTMIterator iterator)
Copy NodeList members into this nodelist, adding in
document order.
|
void |
addNodesInDocOrder(DTMIterator iterator,
XPathContext support)
Copy NodeList members into this nodelist, adding in
document order.
|
void |
allowDetachToRelease(boolean allowRelease)
Specify if it's OK for detach to release the iterator for reuse.
|
void |
appendNodes(NodeVector nodes)
Append the nodes to the list.
|
java.lang.Object |
clone()
Clone this NodeSetDTM.
|
DTMIterator |
cloneWithReset()
Get a cloned Iterator, and reset its state to the beginning of the
iteration.
|
boolean |
contains(int s)
Tell if the table contains the given node.
|
void |
detach()
Detaches the iterator from the set which it iterated over, releasing
any computational resources and placing the iterator in the INVALID
state.
|
int |
elementAt(int i)
Get the nth element.
|
int |
getAxis()
Returns the axis being iterated, if it is known.
|
int |
getCurrentNode()
Return the last fetched node.
|
int |
getCurrentPos()
Get the current position, which is one less than
the next nextNode() call will retrieve.
|
DTM |
getDTM(int nodeHandle)
Get an instance of a DTM that "owns" a node handle.
|
DTMManager |
getDTMManager()
Get an instance of the DTMManager.
|
boolean |
getExpandEntityReferences()
The value of this flag determines whether the children of entity
reference nodes are visible to the iterator.
|
DTMFilter |
getFilter()
The filter object used to screen nodes.
|
int |
getLast() |
int |
getLength()
The number of nodes in the list.
|
int |
getRoot()
The root node of the
DTMIterator, as specified when it
was created. |
boolean |
getShouldCacheNodes()
Get whether or not this is a cached node set.
|
int |
getWhatToShow()
This attribute determines which node types are presented via the
iterator.
|
int |
indexOf(int elem)
Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
|
int |
indexOf(int elem,
int index)
Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
|
void |
insertElementAt(int value,
int at)
Inserts the specified node in this vector at the specified index.
|
void |
insertNode(int n,
int pos)
Insert a node at a given position.
|
boolean |
isDocOrdered()
Returns true if all the nodes in the iteration well be returned in document
order.
|
boolean |
isFresh()
Tells if this NodeSetDTM is "fresh", in other words, if
the first nextNode() that is called will return the
first node in the set.
|
boolean |
isMutable()
Tells if this iterator can have nodes added to it or set via
the
setItem(int node, int index) method. |
int |
item(int index)
Returns the
indexth item in the collection. |
int |
nextNode()
Returns the next node in the set and advances the position of the
iterator in the set.
|
int |
previousNode()
Returns the previous node in the set and moves the position of the
iterator backwards in the set.
|
void |
removeAllElements()
Inserts the specified node in this vector at the specified index.
|
boolean |
removeElement(int s)
Removes the first occurrence of the argument from this vector.
|
void |
removeElementAt(int i)
Deletes the component at the specified index.
|
void |
removeNode(int n)
Remove a node.
|
void |
reset()
Reset the iterator.
|
void |
runTo(int index)
If an index is requested, NodeSetDTM will call this method
to run the iterator to the index.
|
void |
setCurrentPos(int i)
Set the current position in the node set.
|
void |
setElementAt(int node,
int index)
Sets the component at the specified index of this vector to be the
specified object.
|
void |
setEnvironment(java.lang.Object environment)
Set the environment in which this iterator operates, which should provide:
a node (the context node... same value as "root" defined below)
a pair of non-zero positive integers (the context position and the context size)
a set of variable bindings
a function library
the set of namespace declarations in scope for the expression.
|
void |
setItem(int node,
int index)
Same as setElementAt.
|
void |
setLast(int last) |
void |
setRoot(int context,
java.lang.Object environment)
Initialize the context values for this expression
after it is cloned.
|
void |
setShouldCacheNodes(boolean b)
If setShouldCacheNodes(true) is called, then nodes will
be cached.
|
int |
size()
Get the length of the list.
|
insertInOrder, peepOrNull, peepTail, peepTailSub1, pop, popAndTop, popPair, popQuick, push, pushPair, RemoveAllNoClear, setTail, setTailSub1, sort, sortpublic NodeSetDTM(DTMManager dtmManager)
public NodeSetDTM(int blocksize,
int dummy,
DTMManager dtmManager)
blocksize - Size of blocks to allocatedummy - pass zero for right now...public NodeSetDTM(NodeSetDTM nodelist)
nodelist - Set of Nodes to be made members of the new set.public NodeSetDTM(DTMIterator ni)
ni - Iterator which yields Nodes to be made members of the new set.public NodeSetDTM(NodeIterator iterator, XPathContext xctxt)
iterator - Iterator which yields Nodes to be made members of the new set.public NodeSetDTM(NodeList nodeList, XPathContext xctxt)
public NodeSetDTM(int node,
DTMManager dtmManager)
node - Single node to be added to the new set.public void setEnvironment(java.lang.Object environment)
At this time the exact implementation of this environment is application dependent. Probably a proper interface will be created fairly soon.
environment - The environment object.public int getRoot()
DTMIteratorDTMIterator, as specified when it
was created. Note the root node is not the root node of the
document tree, but the context node from where the iteration
begins and ends.getRoot in interface DTMIteratorpublic void setRoot(int context,
java.lang.Object environment)
setRoot in interface DTMIteratorcontext - The XPath runtime context for this
transformation.environment - The environment object.
The environment in which this iterator operates, which should provide:
At this time the exact implementation of this environment is application dependent. Probably a proper interface will be created fairly soon.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface DTMIteratorclone in class NodeVectorjava.lang.CloneNotSupportedException - if this subclass of NodeSetDTM
does not support the clone() operation.public DTMIterator cloneWithReset() throws java.lang.CloneNotSupportedException
cloneWithReset in interface DTMIteratorjava.lang.CloneNotSupportedException - if this subclass of NodeSetDTM
does not support the clone() operation.public void reset()
reset in interface DTMIteratorpublic int getWhatToShow()
DTMFilter interface. For NodeSetDTMs, the mask has been
hardcoded to show all nodes except EntityReference nodes, which have
no equivalent in the XPath data model.getWhatToShow in interface DTMIteratorSHOW_ALL & ~SHOW_ENTITY_REFERENCE, meaning that
only entity references are suppressed.public DTMFilter getFilter()
public boolean getExpandEntityReferences()
getExpandEntityReferences in interface DTMIteratorpublic DTM getDTM(int nodeHandle)
getDTM in interface DTMIteratornodeHandle - the nodeHandle.public DTMManager getDTMManager()
getDTMManager in interface DTMIteratorpublic int nextNode()
nextNode in interface DTMIteratorNode in the set being iterated over, or
DTM.NULL if there are no more members in that set.DOMException - INVALID_STATE_ERR: Raised if this method is called after the
detach method was invoked.public int previousNode()
previousNode in interface DTMIteratorNode in the set being iterated over,
orDTM.NULL if there are no more members in that set.DOMException - INVALID_STATE_ERR: Raised if this method is called after the
detach method was invoked.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a cached type, and hence doesn't know what the previous node was.public void detach()
detach has been invoked, calls to
nextNode orpreviousNode will raise the
exception INVALID_STATE_ERR.
This operation is a no-op in NodeSetDTM, and will not cause INVALID_STATE_ERR to be raised by later operations.
detach in interface DTMIteratorpublic void allowDetachToRelease(boolean allowRelease)
allowDetachToRelease in interface DTMIteratorallowRelease - true if it is OK for detach to release this iterator
for pooling.public boolean isFresh()
isFresh in interface DTMIteratorpublic void runTo(int index)
runTo in interface DTMIteratorindex - Position to advance (or retreat) to, with
0 requesting the reset ("fresh") position and -1 (or indeed
any out-of-bounds value) requesting the final position.java.lang.RuntimeException - thrown if this NodeSetDTM is not
one of the types which supports indexing/counting.public int item(int index)
indexth item in the collection. If
index is greater than or equal to the number of nodes in
the list, this returns null.
TODO: What happens if index is out of range?item in interface DTMIteratorindex - Index into the collection.indexth position in the
NodeList, or null if that is not a valid
index.public int getLength()
length-1 inclusive. Note that this operation requires
finding all the matching nodes, which may defeat attempts to defer
that work.getLength in interface DTMIteratorpublic void addNode(int n)
n - Node to be addedjava.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void insertNode(int n,
int pos)
n - Node to be addedpos - Offset at which the node is to be inserted,
with 0 being the first position.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void removeNode(int n)
n - Node to be addedjava.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void addNodes(DTMIterator iterator)
iterator - DTMIterator which yields the nodes to be added.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
iterator - DTMIterator which yields the nodes to be added.support - The XPath runtime context.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public int addNodeInDocOrder(int node,
boolean test,
XPathContext support)
node - The node to be added.test - true if we should test for doc ordersupport - The XPath runtime context.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public int addNodeInDocOrder(int node,
XPathContext support)
node - The node to be added.support - The XPath runtime context.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public int size()
size in class NodeVectorpublic void addElement(int value)
addElement in class NodeVectorvalue - The node to be added.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void insertElementAt(int value,
int at)
insertElementAt in class NodeVectorvalue - The node to be inserted.at - The index where the insert should occur.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void appendNodes(NodeVector nodes)
appendNodes in class NodeVectornodes - The nodes to be appended to this node set.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void removeAllElements()
removeAllElements in class NodeVectorjava.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public boolean removeElement(int s)
removeElement in class NodeVectors - The node to be removed.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void removeElementAt(int i)
removeElementAt in class NodeVectori - The index of the node to be removed.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void setElementAt(int node,
int index)
setElementAt in class NodeVectornode - The node to be set.index - The index of the node to be replaced.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public void setItem(int node,
int index)
setItem in interface DTMIteratornode - The node to be set.index - The index of the node to be replaced.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a mutable type.public int elementAt(int i)
elementAt in class NodeVectori - The index of the requested node.public boolean contains(int s)
contains in class NodeVectors - Node to look forpublic int indexOf(int elem,
int index)
indexOf in class NodeVectorelem - Node to look forindex - Index of where to start the searchpublic int indexOf(int elem)
indexOf in class NodeVectorelem - Node to look forpublic int getCurrentPos()
getCurrentPos in interface DTMIteratorpublic void setCurrentPos(int i)
setCurrentPos in interface DTMIteratori - Must be a valid index.java.lang.RuntimeException - thrown if this NodeSetDTM is not of
a cached type, and thus doesn't permit indexed access.public int getCurrentNode()
getCurrentNode in interface DTMIteratorjava.lang.RuntimeException - thrown if this NodeSetDTM is not of
a cached type, and thus doesn't permit indexed access.public boolean getShouldCacheNodes()
public void setShouldCacheNodes(boolean b)
setShouldCacheNodes in interface DTMIteratorb - true if this node set should be cached.java.lang.RuntimeException - thrown if an attempt is made to
request caching after we've already begun stepping through the
nodes in this set.public boolean isMutable()
setItem(int node, int index) method.isMutable in interface DTMIteratorpublic int getLast()
public void setLast(int last)
public boolean isDocOrdered()
isDocOrdered in interface DTMIteratorpublic int getAxis()
getAxis in interface DTMIteratorCopyright © 2014 Apache XML Project. All Rights Reserved.