public class NodeSetDTM extends NodeVector implements DTMIterator, Cloneable
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.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_cacheNodes
True if this list is cached.
|
protected int |
m_next
If this node is being used as an iterator, the next index that nextNode() will return.
|
protected int |
m_root
The root of the iteration, if available.
|
m_firstFreeFILTER_ACCEPT, 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNode(int n)
Add a node to the NodeSetDTM.
|
void |
addNodeInDocOrder(int node,
boolean test,
XPathContext support)
Add the node into a vector of nodes where it should occur in document order.
|
void |
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 |
allowDetachToRelease(boolean allowRelease)
Specify if it's OK for detach to release the iterator for reuse.
|
Object |
clone() |
DTMIterator |
cloneWithReset()
Get a cloned Iterator that is reset to the start of the iteration.
|
boolean |
contains(int s)
Tell if the table contains the given node.
|
void |
detach()
Detaches the
DTMIterator 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()
Get the current node in the iterator.
|
int |
getCurrentPos()
Get the current position within the cached list, 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.
|
int |
getLength()
The number of nodes in the list.
|
int |
getRoot()
The root node of the
DTMIterator, as specified when it was created. |
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.
|
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.
|
int |
item(int index)
Returns the
node handle of an 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
DTMIterator
backwards in the set. |
void |
reset()
Reset the iterator to the start.
|
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 |
setRoot(int context,
Object environment)
Reset the root node of the
DTMIterator, overriding the value specified when it was
created. |
void |
setShouldCacheNodes(boolean b)
If setShouldCacheNodes(true) is called, then nodes will be cached, enabling random access, and
giving the ability to do sorts and the like.
|
addElement, insertElementAt, peepOrNull, RemoveAllNoClear, sizeprotected transient int m_next
protected transient boolean m_cacheNodes
protected int m_root
public NodeSetDTM(DTMManager dtmManager)
public NodeSetDTM(DTMIterator ni)
ni - Iterator which yields Nodes to be made members of the new set.public int getRoot()
DTMIterator, 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,
Object environment)
DTMIterator, overriding the value 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.setRoot in interface DTMIteratorcontext - int Handle of the context node.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 Object clone() throws CloneNotSupportedException
clone in interface DTMIteratorclone in class NodeVectorCloneNotSupportedException - if anypublic DTMIterator cloneWithReset() throws CloneNotSupportedException
cloneWithReset in interface DTMIteratorCloneNotSupportedException - if anypublic void reset()
reset in interface DTMIteratorpublic int getWhatToShow()
whatToShow will be skipped, but
their children may still be considered.getWhatToShow in interface DTMIteratorpublic boolean getExpandEntityReferences()
whatToShow and the filter.
To produce a view of the document that has entity references expanded and does not expose
the entity reference node itself, use the whatToShow flags to hide the entity
reference node and set expandEntityReferences to true when creating the iterator.
To produce a view of the document that has entity reference nodes but no entity expansion, use
the whatToShow flags to show the entity reference node and set
expandEntityReferences to false.
NOTE: In Xalan's use of DTM we will generally have fully expanded entity references when the document tree was built, and thus this flag will have no effect.
getExpandEntityReferences in interface DTMIteratorpublic DTM getDTM(int nodeHandle)
getDTM in interface DTMIteratornodeHandle - the nodeHandle.public DTMManager getDTMManager()
getDTMManager in interface DTMIteratorpublic int nextNode()
DTMIterator has setRoot called, the first call to nextNode() returns
that root or (if it is rejected by the filters) the first node within its subtree which is not
filtered out.nextNode in interface DTMIteratorDTM.NULL if there
are no more members in that set.public int previousNode()
DTMIterator
backwards in the set.previousNode in interface DTMIteratorDTM.NULL if
there are no more members in that set.public void detach()
DTMIterator from the set which it iterated over, releasing any
computational resources and placing the iterator in the INVALID state. After detach
has been invoked, calls to nextNode or previousNode will
raise a runtime exception.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 - The index to run to, or -1 if the iterator should be run to the end.public int item(int index)
node handle of an item in the collection. If index is
greater than or equal to the number of nodes in the list, this returns null.item in interface DTMIteratorindex - of the item.indexth position in the DTMIterator,
or -1 if that is not a valid index.public int getLength()
length-1
inclusive. Note that this requires running the iterator to completion, and presumably
filling the cache.getLength in interface DTMIteratorpublic void addNode(int n)
n - Node to be addedRuntimeException - thrown if this NodeSetDTM is not of a mutable type.public void addNodes(DTMIterator iterator)
iterator - DTMIterator which yields the nodes to be added.RuntimeException - thrown if this NodeSetDTM is not of a mutable type.public void 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.RuntimeException - thrown if this NodeSetDTM is not of a mutable type.public void addNodeInDocOrder(int node,
XPathContext support)
node - The node to be added.support - The XPath runtime context.RuntimeException - thrown if this NodeSetDTM is not of a mutable type.public int elementAt(int i)
elementAt in class NodeVectori - Index of node to getpublic 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.public int getCurrentNode()
getCurrentNode in interface DTMIteratorpublic void setShouldCacheNodes(boolean b)
%REVIEW% Shouldn't the other random-access methods throw an exception if they're called on a DTMIterator with this flag set false?
setShouldCacheNodes in interface DTMIteratorb - true if the nodes should be cached.public boolean isDocOrdered()
isDocOrdered in interface DTMIteratorpublic int getAxis()
getAxis in interface DTMIteratorCopyright © 2022. All rights reserved.