org.apache.xpath.axes

Class FilterExprWalker

Implemented Interfaces:
Cloneable, ExpressionNode, ExpressionOwner, PathComponent, java.io.Serializable, SourceLocator, SubContextList, XPathVisitable

public class FilterExprWalker
extends AxesWalker

Walker for the OP_VARIABLE, or OP_EXTFUNCTION, or OP_FUNCTION, or OP_GROUP, op codes.
See Also:
XPath FilterExpr descriptions, Serialized Form

Field Summary

Fields inherited from class org.apache.xpath.patterns.NodeTest

SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, SUPPORTS_PRE_STRIPPING, WILD

Constructor Summary

FilterExprWalker(WalkingIterator locPathIterator)
Construct a FilterExprWalker using a LocPathIterator.

Method Summary

short
acceptNode(int n)
This method needs to override AxesWalker.acceptNode because FilterExprWalkers don't need to, and shouldn't, do a node test.
void
callPredicateVisitors(XPathVisitor visitor)
This will traverse the heararchy, calling the visitor for each member.
Object
clone()
Get a cloned FilterExprWalker.
boolean
deepEquals(Expression expr)
void
detach()
Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
void
fixupVariables(java.util.Vector vars, int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.
int
getAnalysisBits()
Get the analysis bits for this walker, as defined in the WalkerFactory.
int
getAxis()
Returns the axis being iterated, if it is known.
Expression
getInnerExpression()
Get the inner contained expression of this filter.
int
getLastPos(XPathContext xctxt)
Get the index of the last node that can be itterated to.
int
getNextNode()
Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node.
void
init(Compiler compiler, int opPos, int stepType)
Init a FilterExprWalker.
boolean
isDocOrdered()
Returns true if all the nodes in the iteration well be returned in document order.
void
setInnerExpression(Expression expr)
Set the inner contained expression of this filter.
void
setRoot(int root)
Set the root node of the TreeWalker.

Methods inherited from class org.apache.xpath.axes.AxesWalker

callVisitors, clone, deepEquals, detach, getAnalysisBits, getAxis, getCurrentNode, getDTM, getExpression, getLastPos, getNextWalker, getPrevWalker, getRoot, init, isDocOrdered, nextNode, setDefaultDTM, setExpression, setNextWalker, setPrevWalker, setRoot, wi

Methods inherited from class org.apache.xpath.axes.PredicatedNodeTest

acceptNode, callPredicateVisitors, canTraverseOutsideSubtree, clone, deepEquals, fixupVariables, getLastPos, getLocPathIterator, getPredicate, getPredicateCount, getPredicateIndex, getProximityPosition, getProximityPosition, initProximityPosition, isReverseAxes, resetProximityPositions, setLocPathIterator, setPredicateCount

Methods inherited from class org.apache.xpath.patterns.NodeTest

callVisitors, debugWhatToShow, deepEquals, execute, execute, execute, fixupVariables, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShow

Methods inherited from class org.apache.xpath.Expression

asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, deepEquals, error, execute, execute, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, fixupVariables, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isStableNumber, num, warn, xstr

Constructor Details

FilterExprWalker

public FilterExprWalker(WalkingIterator locPathIterator)
Construct a FilterExprWalker using a LocPathIterator.
Parameters:
locPathIterator - non-null reference to the parent iterator.

Method Details

acceptNode

public short acceptNode(int n)
This method needs to override AxesWalker.acceptNode because FilterExprWalkers don't need to, and shouldn't, do a node test.
Overrides:
acceptNode in interface PredicatedNodeTest
Parameters:
n - The node to check to see if it passes the filter or not.
Returns:
a constant to determine whether the node is accepted, rejected, or skipped, as defined above .

callPredicateVisitors

public void callPredicateVisitors(XPathVisitor visitor)
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.
Overrides:
callPredicateVisitors in interface PredicatedNodeTest
Parameters:
visitor - The visitor whose appropriate method will be called.

clone

public Object clone()
            throws CloneNotSupportedException
Get a cloned FilterExprWalker.
Overrides:
clone in interface AxesWalker
Returns:
A new FilterExprWalker that can be used without mutating this one.

deepEquals

public boolean deepEquals(Expression expr)
Overrides:
deepEquals in interface AxesWalker

detach

public void detach()
Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
Overrides:
detach in interface AxesWalker

fixupVariables

public void fixupVariables(java.util.Vector vars,
                           int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.
Overrides:
fixupVariables in interface PredicatedNodeTest
Parameters:
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).

getAnalysisBits

public int getAnalysisBits()
Get the analysis bits for this walker, as defined in the WalkerFactory.
Specified by:
getAnalysisBits in interface PathComponent
Overrides:
getAnalysisBits in interface AxesWalker
Returns:
One of WalkerFactory#BIT_DESCENDANT, etc.

getAxis

public int getAxis()
Returns the axis being iterated, if it is known.
Overrides:
getAxis in interface AxesWalker
Returns:
Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.

getInnerExpression

public Expression getInnerExpression()
Get the inner contained expression of this filter.

getLastPos

public int getLastPos(XPathContext xctxt)
Get the index of the last node that can be itterated to.
Specified by:
getLastPos in interface SubContextList
Overrides:
getLastPos in interface AxesWalker
Parameters:
xctxt - XPath runtime context.
Returns:
the index of the last node that can be itterated to.

getNextNode

public int getNextNode()
Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node. If the current node has no next node, or if the search for nextNode attempts to step upward from the TreeWalker's root node, returns null , and retains the current node.
Returns:
The new node, or null if the current node has no next node in the TreeWalker's logical view.

init

public void init(Compiler compiler,
                 int opPos,
                 int stepType)
            throws TransformerException
Init a FilterExprWalker.
Overrides:
init in interface AxesWalker
Parameters:
compiler - non-null reference to the Compiler that is constructing.
opPos - positive opcode position for this step.
stepType - The type of step.

isDocOrdered

public boolean isDocOrdered()
Returns true if all the nodes in the iteration well be returned in document order. Warning: This can only be called after setRoot has been called!
Overrides:
isDocOrdered in interface AxesWalker
Returns:
true as a default.

setInnerExpression

public void setInnerExpression(Expression expr)
Set the inner contained expression of this filter.

setRoot

public void setRoot(int root)
Set the root node of the TreeWalker.
Overrides:
setRoot in interface AxesWalker
Parameters:
root - non-null reference to the root, or starting point of the query.

Copyright B) 2004 Apache XML Project. All Rights Reserved.