Package org.apache.xpath.axes
Class PredicatedNodeTest
java.lang.Object
org.apache.xpath.Expression
org.apache.xpath.patterns.NodeTest
org.apache.xpath.axes.PredicatedNodeTest
- All Implemented Interfaces:
Serializable,SourceLocator,SubContextList,ExpressionNode,XPathVisitable
- Direct Known Subclasses:
AxesWalker,LocPathIterator
public abstract class PredicatedNodeTest extends NodeTest implements SubContextList
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_foundLastThis is true if nextNode returns null.protected LocPathIteratorm_lpiThe owning location path iterator.protected intm_predCountprotected int[]m_proximityPositionsAn array of counts that correspond to the number of predicates the step contains.Fields inherited from class org.apache.xpath.patterns.NodeTest
m_name, m_whatToShow, SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, SUPPORTS_PRE_STRIPPING, WILD -
Method Summary
Modifier and Type Method Description shortacceptNode(int n)Test whether a specified node is visible in the logical view of a TreeWalker or NodeIterator.voidcallPredicateVisitors(XPathVisitor visitor)This will traverse the heararchy, calling the visitor for each member.booleancanTraverseOutsideSubtree()Tell if this expression or it's subexpressions can traverse outside the current subtree.Objectclone()Get a cloned PrdicatedNodeTest.protected voidcountProximityPosition(int i)Count forward one proximity position.booleandeepEquals(Expression expr)Compare this object with another object and see if they are equal, include the sub heararchy.voidfixupVariables(Vector vars, int globalsSize)This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.abstract intgetLastPos(XPathContext xctxt)Get the index of the last node that can be itterated to.LocPathIteratorgetLocPathIterator()Get the owning location path iterator.ExpressiongetPredicate(int index)Get a predicate expression at the given index.intgetPredicateCount()Get the number of predicates that this walker has.intgetPredicateIndex()Get which predicate is executing.intgetProximityPosition()Get the current sub-context position.protected intgetProximityPosition(int predicateIndex)Get the current sub-context position.intgetProximityPosition(XPathContext xctxt)Get the current sub-context position.protected voidinitPredicateInfo(Compiler compiler, int opPos)Init predicate info.voidinitProximityPosition(int i)Init the proximity position to zero for a forward axes.booleanisReverseAxes()Tells if this is a reverse axes.protected StringnodeToString(int n)Diagnostics.voidresetProximityPositions()Reset the proximity positions counts.voidsetLocPathIterator(LocPathIterator li)Set the location path iterator owner for this walker.voidsetPredicateCount(int count)Set the number of predicates that this walker has.Methods inherited from class org.apache.xpath.patterns.NodeTest
calcScore, callVisitors, debugWhatToShow, execute, execute, execute, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShowMethods inherited from class org.apache.xpath.Expression
asIterator, asIteratorRaw, asNode, assertion, bool, error, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isSameClass, isStableNumber, num, warn, xstr
-
Field Details
-
m_predCount
protected int m_predCount -
m_foundLast
protected transient boolean m_foundLastThis is true if nextNode returns null. -
m_lpi
The owning location path iterator. -
m_proximityPositions
protected transient int[] m_proximityPositionsAn array of counts that correspond to the number of predicates the step contains.
-
-
Method Details
-
clone
Get a cloned PrdicatedNodeTest.- Overrides:
clonein classObject- Returns:
- A new PredicatedNodeTest that can be used without mutating this one.
- Throws:
CloneNotSupportedException
-
getPredicateCount
public int getPredicateCount()Get the number of predicates that this walker has.- Returns:
- the number of predicates that this walker has.
-
setPredicateCount
public void setPredicateCount(int count)Set the number of predicates that this walker has. This does more that one would think, as it creates a new predicate array of the size of the count argument, and copies count predicates into the new one from the old, and then reassigns the predicates value. All this to keep from having to have a predicate count value.- Parameters:
count- The number of predicates, which must be equal or less than the existing count.
-
initPredicateInfo
Init predicate info.- Parameters:
compiler- The Compiler object that has information about this walker in the op map.opPos- The op code position of this location step.- Throws:
TransformerException
-
getPredicate
Get a predicate expression at the given index.- Parameters:
index- Index of the predicate.- Returns:
- A predicate expression.
-
getProximityPosition
public int getProximityPosition()Get the current sub-context position.- Returns:
- The node position of this walker in the sub-context node list.
-
getProximityPosition
Get the current sub-context position.- Specified by:
getProximityPositionin interfaceSubContextList- Parameters:
xctxt- The XPath runtime context.- Returns:
- The node position of this walker in the sub-context node list.
-
getLastPos
Get the index of the last node that can be itterated to.- Specified by:
getLastPosin interfaceSubContextList- Parameters:
xctxt- XPath runtime context.- Returns:
- the index of the last node that can be itterated to.
-
getProximityPosition
protected int getProximityPosition(int predicateIndex)Get the current sub-context position.- Parameters:
predicateIndex- The index of the predicate where the proximity should be taken from.- Returns:
- The node position of this walker in the sub-context node list.
-
resetProximityPositions
public void resetProximityPositions()Reset the proximity positions counts. -
initProximityPosition
Init the proximity position to zero for a forward axes.- Parameters:
i- The index into the m_proximityPositions array.- Throws:
TransformerException
-
countProximityPosition
protected void countProximityPosition(int i)Count forward one proximity position.- Parameters:
i- The index into the m_proximityPositions array, where the increment will occur.
-
isReverseAxes
public boolean isReverseAxes()Tells if this is a reverse axes.- Returns:
- false, unless a derived class overrides.
-
getPredicateIndex
public int getPredicateIndex()Get which predicate is executing.- Returns:
- The current predicate index, or -1 if no predicate is executing.
-
fixupVariables
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.- Overrides:
fixupVariablesin classNodeTest- 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).
-
nodeToString
Diagnostics.- Parameters:
n- Node to give diagnostic information about, or null.- Returns:
- Informative string about the argument.
-
acceptNode
public short acceptNode(int n)Test whether a specified node is visible in the logical view of a TreeWalker or NodeIterator. This function will be called by the implementation of TreeWalker and NodeIterator; it is not intended to be called directly from user code.- 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 .
-
getLocPathIterator
Get the owning location path iterator.- Returns:
- the owning location path iterator, which should not be null.
-
setLocPathIterator
Set the location path iterator owner for this walker. Besides initialization, this function is called during cloning operations.- Parameters:
li- non-null reference to the owning location path iterator.
-
canTraverseOutsideSubtree
public boolean canTraverseOutsideSubtree()Tell if this expression or it's subexpressions can traverse outside the current subtree.- Overrides:
canTraverseOutsideSubtreein classExpression- Returns:
- true if traversal outside the context node's subtree can occur.
-
callPredicateVisitors
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Parameters:
visitor- The visitor whose appropriate method will be called.
-
deepEquals
Description copied from class:ExpressionCompare this object with another object and see if they are equal, include the sub heararchy.- Overrides:
deepEqualsin classNodeTest- Parameters:
expr- Another expression object.- Returns:
- true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
- See Also:
Expression.deepEquals(Expression)
-