public class NodeSequence extends XObject implements DTMIterator, Cloneable, PathComponent
Modifier and Type | Field and Description |
---|---|
protected DTMManager |
m_dtmMgr
The DTMManager to use if we're using a NodeVector only.
|
protected DTMIterator |
m_iter
The functional iterator that fetches nodes.
|
protected int |
m_last
The index of the last node in the iteration.
|
protected int |
m_next
The index of the next node to be fetched.
|
CLASS_BOOLEAN, CLASS_NODESET, CLASS_NULL, CLASS_NUMBER, CLASS_RTREEFRAG, CLASS_STRING, CLASS_UNKNOWN, CLASS_UNRESOLVEDVARIABLE, m_obj
FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP
Constructor and Description |
---|
NodeSequence()
Create a new NodeSequence in an invalid (null) state.
|
NodeSequence(Object nodeVector)
Create a new NodeSequence from a (already cloned) iterator.
|
Modifier and Type | Method and Description |
---|---|
protected int |
addNodeInDocOrder(int node)
Add the node into a vector of nodes where it should occur in
document order.
|
void |
allowDetachToRelease(boolean allowRelease)
Calling this with a value of false will cause the nodeset
to be cached.
|
Object |
clone()
Get a clone of this iterator, but don't reset the iteration in the
process, so that it may be used from the current position.
|
DTMIterator |
cloneWithReset()
Note: Not a deep clone.
|
void |
detach()
Detaches the
DTMIterator from the set which it iterated
over, releasing any computational resources and placing the iterator
in the INVALID state. |
void |
fixupVariables(Vector vars,
int globalsSize)
XObjects should not normally need to fix up variables.
|
int |
getAnalysisBits()
Get the analysis bits for this path component, as defined in the WalkerFactory.
|
int |
getAxis()
Returns the axis being iterated, if it is known.
|
DTMIterator |
getContainedIter()
Get the functional iterator that fetches nodes.
|
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.
|
protected org.apache.xpath.axes.NodeSequence.IteratorCache |
getIteratorCache()
Get the cached list of nodes appended with
values obtained from the iterator as
a NodeSequence is walked when its
nextNode() method is called.
|
int |
getLength()
The number of nodes in the list.
|
int |
getRoot()
The root node of the
DTMIterator , as specified when it
was created. |
protected NodeVector |
getVector()
If this iterator needs to cache nodes that are fetched, they
are stored in the Vector in the generic object.
|
int |
getWhatToShow()
This attribute determines which node types are presented via the
iterator.
|
boolean |
hasCache()
If the iterator needs to cache nodes as they are fetched,
then this method returns true.
|
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
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 for fresh reuse.
|
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 |
setItem(int node,
int index)
Sets the node at the specified index of this vector to be the
specified node.
|
void |
setIter(DTMIterator iter)
Set the functional iterator that fetches nodes.
|
protected void |
setObject(Object obj)
It used to be that many locations in the code simply
did an assignment to this.m_obj directly, rather than
calling the setObject(Object) method.
|
void |
setRoot(int nodeHandle,
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.
|
protected void |
SetVector(NodeVector v)
Set the vector where nodes will be cached.
|
appendToFsb, bool, boolWithSideEffects, callVisitors, castToType, create, create, deepEquals, destruct, dispatchCharactersEvents, equals, error, error, execute, getFresh, getType, getTypeString, greaterThan, greaterThanOrEqual, iter, lessThan, lessThanOrEqual, mutableNodeset, nodelist, nodeset, notEquals, num, numWithSideEffects, object, rtf, rtf, rtree, rtree, str, toString, xstr
asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isSameClass, isStableNumber, num, warn, xstr
protected int m_last
protected int m_next
protected DTMIterator m_iter
protected DTMManager m_dtmMgr
public NodeSequence(Object nodeVector)
nodeVector
- public NodeSequence()
protected NodeVector getVector()
protected void SetVector(NodeVector v)
public boolean hasCache()
public final void setIter(DTMIterator iter)
iter
- The iterator that is to be contained.public final DTMIterator getContainedIter()
public DTM getDTM(int nodeHandle)
DTMIterator
getDTM
in interface DTMIterator
nodeHandle
- the nodeHandle.DTMIterator.getDTM(int)
public DTMManager getDTMManager()
DTMIterator
getDTMManager
in interface DTMIterator
DTMIterator.getDTMManager()
public int getRoot()
DTMIterator
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 DTMIterator
DTMIterator.getRoot()
public void setRoot(int nodeHandle, Object environment)
DTMIterator
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 DTMIterator
nodeHandle
- 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.
DTMIterator.setRoot(int, Object)
public void reset()
XObject
reset
in interface DTMIterator
reset
in class XObject
DTMIterator.reset()
public int getWhatToShow()
DTMIterator
whatToShow
will be skipped, but their children may still
be considered.getWhatToShow
in interface DTMIterator
DTMIterator.getWhatToShow()
public boolean getExpandEntityReferences()
DTMIterator
The value of this flag determines whether the children of entity
reference nodes are visible to the iterator. If false, they and
their descendants will be rejected. Note that this rejection takes
precedence over 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 DTMIterator
DTMIterator.getExpandEntityReferences()
public int nextNode()
DTMIterator
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 DTMIterator
DTM.NULL
if there are no more members in that set.DTMIterator.nextNode()
public int previousNode()
DTMIterator
DTMIterator
backwards in the set.previousNode
in interface DTMIterator
DTM.NULL
if there are no more members in that set.DTMIterator.previousNode()
public void detach()
XObject
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 DTMIterator
detach
in class XObject
DTMIterator.detach()
public void allowDetachToRelease(boolean allowRelease)
allowDetachToRelease
in interface DTMIterator
allowDetachToRelease
in class XObject
allowRelease
- true if it is OK for detach to release this iterator
for pooling.DTMIterator.allowDetachToRelease(boolean)
public int getCurrentNode()
DTMIterator
getCurrentNode
in interface DTMIterator
DTMIterator.getCurrentNode()
public boolean isFresh()
DTMIterator
isFresh
in interface DTMIterator
DTMIterator.isFresh()
public void setShouldCacheNodes(boolean b)
DTMIterator
setShouldCacheNodes
in interface DTMIterator
b
- true if the nodes should be cached.DTMIterator.setShouldCacheNodes(boolean)
public boolean isMutable()
DTMIterator
setItem(int node, int index)
method.isMutable
in interface DTMIterator
DTMIterator.isMutable()
public int getCurrentPos()
DTMIterator
getCurrentPos
in interface DTMIterator
DTMIterator.getCurrentPos()
public void runTo(int index)
DTMIterator
runTo
in interface DTMIterator
index
- The index to run to, or -1 if the iterator should be run
to the end.DTMIterator.runTo(int)
public void setCurrentPos(int i)
DTMIterator
setCurrentPos
in interface DTMIterator
i
- Must be a valid index.DTMIterator.setCurrentPos(int)
public int item(int index)
DTMIterator
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 DTMIterator
index
- of the item.index
th position in the
DTMIterator
, or -1
if that is not a valid
index.DTMIterator.item(int)
public void setItem(int node, int index)
DTMIterator
The index must be a value greater than or equal to 0 and less than the current size of the vector. The iterator must be in cached mode.
Meant to be used for sorted iterators.
setItem
in interface DTMIterator
node
- Node to setindex
- Index of where to set the nodeDTMIterator.setItem(int, int)
public int getLength()
DTMIterator
length-1
inclusive. Note that this requires running
the iterator to completion, and presumably filling the cache.getLength
in interface DTMIterator
DTMIterator.getLength()
public DTMIterator cloneWithReset() throws CloneNotSupportedException
cloneWithReset
in interface DTMIterator
CloneNotSupportedException
DTMIterator.cloneWithReset()
public Object clone() throws CloneNotSupportedException
clone
in interface DTMIterator
clone
in class Object
CloneNotSupportedException
public boolean isDocOrdered()
DTMIterator
isDocOrdered
in interface DTMIterator
DTMIterator.isDocOrdered()
public int getAxis()
DTMIterator
getAxis
in interface DTMIterator
DTMIterator.getAxis()
public int getAnalysisBits()
PathComponent
getAnalysisBits
in interface PathComponent
PathComponent.getAnalysisBits()
public void fixupVariables(Vector vars, int globalsSize)
XObject
fixupVariables
in class XObject
vars
- List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
NEEDSDOC @param globalsSizeExpression.fixupVariables(Vector, int)
protected int addNodeInDocOrder(int node)
node
- The node to be added.RuntimeException
- thrown if this NodeSetDTM is not of
a mutable type.protected void setObject(Object obj)
All setting of m_obj is done through setObject() now, and this method over-rides the super-class method. So now we are in the loop have an opportunity to update some caching information.
protected org.apache.xpath.axes.NodeSequence.IteratorCache getIteratorCache()
Copyright © 2016 JBoss by Red Hat. All rights reserved.