org.apache.xpath.patterns

Class StepPattern

public class StepPattern extends NodeTest implements SubContextList, ExpressionOwner

This class represents a single pattern match step.

UNKNOWN: advanced

Constructor Summary
StepPattern(int whatToShow, String namespace, String name, int axis, int axisForPredicate)
Construct a StepPattern that tests for namespaces and node names.
StepPattern(int whatToShow, int axis, int axisForPredicate)
Construct a StepPattern that doesn't test for node names.
Method Summary
voidcalcScore()
Static calc of match score.
voidcalcTargetString()
Calculate the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.
voidcallVisitors(ExpressionOwner owner, XPathVisitor visitor)
booleancanTraverseOutsideSubtree()
Tell if this expression or it's subexpressions can traverse outside the current subtree.
booleandeepEquals(Expression expr)
XObjectexecute(XPathContext xctxt, int currentNode)
Execute this pattern step, including predicates.
XObjectexecute(XPathContext xctxt)
Execute this pattern step, including predicates.
XObjectexecute(XPathContext xctxt, int currentNode, DTM dtm, int expType)
Execute an expression in the XPath runtime context, and return the result of the expression.
voidfixupVariables(Vector vars, int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.
intgetAxis()
Get the axis that this step follows.
ExpressiongetExpression()
intgetLastPos(XPathContext xctxt)
Get the count of the nodes that match the test, which is the proximity position of the last node that can pass this test in the sub context selection.
doublegetMatchScore(XPathContext xctxt, int context)
Get the match score of the given node.
ExpressiongetPredicate(int i)
Get a predicate expression.
intgetPredicateCount()
Get the number of predicates for this match pattern step.
Expression[]getPredicates()
Set the list of predicate expressions for this pattern step.
intgetProximityPosition(XPathContext xctxt)
Get the proximity position index of the current node based on this node test.
StepPatterngetRelativePathPattern()
Get the reference to nodetest and predicate for parent or ancestor.
StringgetTargetString()
Get the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.
voidsetAxis(int axis)
Set the axis that this step should follow.
voidsetExpression(Expression exp)
voidsetPredicates(Expression[] predicates)
Set the predicates for this match pattern step.
voidsetRelativePathPattern(StepPattern expr)
Set the reference to nodetest and predicate for parent or ancestor.
StringtoString()
Get the string represenentation of this step for diagnostic purposes.

Constructor Detail

StepPattern

public StepPattern(int whatToShow, String namespace, String name, int axis, int axisForPredicate)
Construct a StepPattern that tests for namespaces and node names.

Parameters: whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}. namespace The namespace to be tested. name The local name to be tested. axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc. axisForPredicate No longer used.

StepPattern

public StepPattern(int whatToShow, int axis, int axisForPredicate)
Construct a StepPattern that doesn't test for node names.

Parameters: whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}. axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc. axisForPredicate No longer used.

Method Detail

calcScore

public void calcScore()
Static calc of match score.

calcTargetString

public void calcTargetString()
Calculate the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.

See Also: PsuedoNames

callVisitors

public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)

See Also: XPathVisitable

canTraverseOutsideSubtree

public boolean canTraverseOutsideSubtree()
Tell if this expression or it's subexpressions can traverse outside the current subtree. NOTE: Ancestors tests with predicates are problematic, and will require special treatment.

Returns: true if traversal outside the context node's subtree can occur.

deepEquals

public boolean deepEquals(Expression expr)

See Also: deepEquals

execute

public XObject execute(XPathContext xctxt, int currentNode)
Execute this pattern step, including predicates.

Parameters: xctxt XPath runtime context. currentNode The current node context.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

execute

public XObject execute(XPathContext xctxt)
Execute this pattern step, including predicates.

Parameters: xctxt XPath runtime context.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

execute

public XObject execute(XPathContext xctxt, int currentNode, DTM dtm, int expType)
Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters: xctxt The XPath runtime context. currentNode The currentNode. dtm The DTM of the current node. expType The expanded type ID of the current node.

Returns: The result of the expression in the form of a XObject.

Throws: javax.xml.transform.TransformerException if a runtime exception occurs.

fixupVariables

public void fixupVariables(Vector vars, int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

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). globalsSize The number of variables in the global variable area.

getAxis

public int getAxis()
Get the axis that this step follows.

Returns: The Axis for this test, one of of Axes.ANCESTORORSELF, etc.

getExpression

public Expression getExpression()

See Also: getExpression

getLastPos

public int getLastPos(XPathContext xctxt)
Get the count of the nodes that match the test, which is the proximity position of the last node that can pass this test in the sub context selection. In XSLT 1-based indexing, this count is the index of the last node.

Parameters: xctxt XPath runtime context.

Returns: the count of the nodes that match the test.

getMatchScore

public double getMatchScore(XPathContext xctxt, int context)
Get the match score of the given node.

Parameters: xctxt The XPath runtime context. context The node to be tested.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

getPredicate

public Expression getPredicate(int i)
Get a predicate expression.

Parameters: i The index of the predicate.

Returns: A predicate expression.

getPredicateCount

public final int getPredicateCount()
Get the number of predicates for this match pattern step.

Returns: the number of predicates for this match pattern step.

getPredicates

public Expression[] getPredicates()
Set the list of predicate expressions for this pattern step.

Returns: List of expression objects.

getProximityPosition

public int getProximityPosition(XPathContext xctxt)
Get the proximity position index of the current node based on this node test.

Parameters: xctxt XPath runtime context.

Returns: the proximity position index of the current node based on the node test.

getRelativePathPattern

public StepPattern getRelativePathPattern()
Get the reference to nodetest and predicate for parent or ancestor.

Returns: The relative pattern expression.

getTargetString

public String getTargetString()
Get the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.

Returns: local name or psuedo name of the node.

See Also: PsuedoNames

setAxis

public void setAxis(int axis)
Set the axis that this step should follow.

Parameters: axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc.

setExpression

public void setExpression(Expression exp)

See Also: setExpression

setPredicates

public void setPredicates(Expression[] predicates)
Set the predicates for this match pattern step.

Parameters: predicates An array of expressions that define predicates for this step.

setRelativePathPattern

public void setRelativePathPattern(StepPattern expr)
Set the reference to nodetest and predicate for parent or ancestor.

Parameters: expr The relative pattern expression.

toString

public String toString()
Get the string represenentation of this step for diagnostic purposes.

Returns: A string representation of this step, built by reverse-engineering the contained info.

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