APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.org.apache.xpath.internal.patterns

public Class StepPattern

extends NodeTest
implements SubContextList, ExpressionOwner
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xpath.internal.ExpressionOwner, com.sun.org.apache.xpath.internal.axes.SubContextList
Known Direct Subclasses
com.sun.org.apache.xpath.internal.patterns.ContextMatchStepPattern, com.sun.org.apache.xpath.internal.patterns.FunctionPattern
Imports
com.sun.org.apache.xml.internal.dtm.Axis, .DTM, .DTMAxisTraverser, .DTMFilter, com.sun.org.apache.xml.internal.utils.QName, com.sun.org.apache.xpath.internal.Expression, .ExpressionOwner, .XPathContext, .XPathVisitor, com.sun.org.apache.xpath.internal.axes.SubContextList, com.sun.org.apache.xpath.internal.compiler.PsuedoNames, com.sun.org.apache.xpath.internal.objects.XObject, java.util.List

This class represents a single pattern match step.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private static final boolean
DEBUG_MATCHES

Set to true to send diagnostics about pattern matches to the consol.

protected int
m_axis

The axis for this test.

pack-priv Expression[]
m_predicates

The list of predicate expressions for this pattern step.

pack-priv StepPattern
m_relativePathPattern

Reference to nodetest and predicate for parent or ancestor.

pack-priv String
m_targetString

The target local name or psuedo name, for hash table lookup optimization.

pack-priv static final long
Inherited from com.sun.org.apache.xpath.internal.patterns.NodeTest:
m_namem_namespacem_scorem_whatToShowSCORE_NODETESTSCORE_NONESCORE_NSWILDSCORE_OTHERSCORE_QNAMESHOW_BYFUNCTIONSUPPORTS_PRE_STRIPPINGWILD

Constructor Summary

AccessConstructor and Description
public
StepPattern(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
,
String
The namespace to be tested.
namespace
,
String
The local name to be tested.
name
,
int
The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
axis
,
int
No longer used.
axisForPredicate
)

Construct a StepPattern that tests for namespaces and node names.

public
StepPattern(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
,
int
The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
axis
,
int
No longer used.
axisForPredicate
)

Construct a StepPattern that doesn't test for node names.

Method Summary

Modifier and TypeMethod and Description
public void
public void
calcTargetString()

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

protected void
callSubtreeVisitors(XPathVisitor visitor)

Call the visitors on the subtree.

public void
callVisitors(ExpressionOwner owner, XPathVisitor visitor)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.callVisitors.

Implements com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

This will traverse the heararchy, calling the visitor for each member.

public boolean

Returns:

true if traversal outside the context node's subtree can occur.
canTraverseOutsideSubtree
()

Overrides com.sun.org.apache.xpath.internal.Expression.canTraverseOutsideSubtree.

Tell if this expression or it's subexpressions can traverse outside the current subtree.

private final boolean

Returns:

true of the position of the context matches pos, false otherwise.
checkProximityPosition
(XPathContext
The XPath runtime context.
xctxt
,
int
Which predicate we're evaluating of foo[1][2][3].
predPos
,
DTM
The DTM of the current node.
dtm
,
int
The currentNode.
context
,
int
The position being requested, i.e. the value returned by m_predicates[predPos].execute(xctxt).
pos
)

New Method to check whether the current node satisfies a position predicate

public boolean
deepEquals(Expression expr)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.deepEquals.

Compare this object with another object and see if they are equal, include the sub heararchy.

public XObject
public XObject
public XObject

Returns:

The result of the expression in the form of a XObject.
execute
(XPathContext
The XPath runtime context.
xctxt
,
int
The currentNode.
currentNode
,
DTM
The DTM of the current node.
dtm
,
int
The expanded type ID of the current node.
expType
)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.execute.

Execute an expression in the XPath runtime context, and return the result of the expression.

protected final boolean

Returns:

true if the node should be accepted, false otherwise.
executePredicates
(XPathContext
The XPath runtime context.
xctxt
,
DTM
The DTM of the current node.
dtm
,
int
The current node context.
currentNode
)

Execute the predicates on this step to determine if the current node should be filtered or accepted.

protected final XObject
public void
fixupVariables(List<QName>
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).
vars
,
int
The number of variables in the global variable area.
globalsSize
)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.fixupVariables.

This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

public int

Returns:

The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
getAxis
()

Get the axis that this step follows.

public Expression
getExpression()

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Get the raw Expression object that this class wraps.

public int

Returns:

the count of the nodes that match the test.
getLastPos
(XPathContext
XPath runtime context.
xctxt
)

Implements com.sun.org.apache.xpath.internal.axes.SubContextList.getLastPos.

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.

public double
public Expression

Returns:

A predicate expression.
getPredicate
(int
The index of the predicate.
i
)

Get a predicate expression.

public final int

Returns:

the number of predicates for this match pattern step.
getPredicateCount
()

Get the number of predicates for this match pattern step.

public Expression[]

Returns:

List of expression objects.
getPredicates
()

Set the list of predicate expressions for this pattern step.

private final int

Returns:

the proximity position index of the current node based on the node test.
getProximityPosition
(XPathContext
XPath runtime context.
xctxt
,
int
Which predicate we're evaluating of foo[1][2][3].
predPos
,
boolean
If true, don't terminate when the context node is found.
findLast
)

Get the proximity position index of the current node based on this node test.

public int

Returns:

the proximity position index of the current node based on the node test.
getProximityPosition
(XPathContext
XPath runtime context.
xctxt
)

Implements com.sun.org.apache.xpath.internal.axes.SubContextList.getProximityPosition.

Get the proximity position index of the current node based on this node test.

public StepPattern

Returns:

The relative pattern expression.
getRelativePathPattern
()

Get the reference to nodetest and predicate for parent or ancestor.

public String

Returns:

local name or psuedo name of the node.
getTargetString
()

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

public void
setAxis(int
The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
axis
)

Set the axis that this step should follow.

public void
setExpression(Expression exp)

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Set the raw expression object for this object.

public void
setPredicates(Expression[]
An array of expressions that define predicates for this step.
predicates
)

Set the predicates for this match pattern step.

public void
setRelativePathPattern(StepPattern
The relative pattern expression.
expr
)

Set the reference to nodetest and predicate for parent or ancestor.

public String

Returns:

A string representation of this step, built by reverse-engineering the contained info.
toString
()

Overrides java.lang.Object.toString.

Get the string represenentation of this step for diagnostic purposes.

Inherited from com.sun.org.apache.xpath.internal.patterns.NodeTest:
debugWhatToShowgetDefaultScoregetLocalNamegetNamespacegetNodeTypeTestgetStaticScoregetWhatToShowinitNodeTestinitNodeTestsetLocalNamesetNamespacesetStaticScoresetWhatToShow

Field Detail

DEBUG_MATCHESback to summary
private static final boolean DEBUG_MATCHES

Set to true to send diagnostics about pattern matches to the consol.

m_axisback to summary
protected int m_axis

The axis for this test.

m_predicatesback to summary
pack-priv Expression[] m_predicates

The list of predicate expressions for this pattern step.

m_relativePathPatternback to summary
pack-priv StepPattern m_relativePathPattern

Reference to nodetest and predicate for parent or ancestor.

m_targetStringback to summary
pack-priv String m_targetString

The target local name or psuedo name, for hash table lookup optimization.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides com.sun.org.apache.xpath.internal.patterns.NodeTest.serialVersionUID.

Constructor Detail

StepPatternback to summary
public StepPattern(int whatToShow, String namespace, String name, int axis, int axisForPredicate)

Construct a StepPattern that tests for namespaces and node names.

Parameters
whatToShow:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

namespace:String

The namespace to be tested.

name:String

The local name to be tested.

axis:int

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

axisForPredicate:int

No longer used.

StepPatternback to summary
public StepPattern(int whatToShow, int axis, int axisForPredicate)

Construct a StepPattern that doesn't test for node names.

Parameters
whatToShow:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

axis:int

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

axisForPredicate:int

No longer used.

Method Detail

calcScoreback to summary
public void calcScore()

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.calcScore.

Static calc of match score.

calcTargetStringback to summary
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
com.sun.org.apache.xpath.internal.compiler.PsuedoNames
callSubtreeVisitorsback to summary
protected void callSubtreeVisitors(XPathVisitor visitor)

Call the visitors on the subtree. Factored out from callVisitors so it may be called by derived classes.

callVisitorsback to summary
public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.callVisitors.

Implements com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

Doc from com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.

See Also
com.sun.org.apache.xpath.internal.XPathVisitable#callVisitors(ExpressionOwner, XPathVisitor)
canTraverseOutsideSubtreeback to summary
public boolean canTraverseOutsideSubtree()

Overrides com.sun.org.apache.xpath.internal.Expression.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:boolean

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

checkProximityPositionback to summary
private final boolean checkProximityPosition(XPathContext xctxt, int predPos, DTM dtm, int context, int pos)

New Method to check whether the current node satisfies a position predicate

Parameters
xctxt:XPathContext

The XPath runtime context.

predPos:int

Which predicate we're evaluating of foo[1][2][3].

dtm:DTM

The DTM of the current node.

context:int

The currentNode.

pos:int

The position being requested, i.e. the value returned by m_predicates[predPos].execute(xctxt).

Returns:boolean

true of the position of the context matches pos, false otherwise.

deepEqualsback to summary
public boolean deepEquals(Expression expr)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.deepEquals.

Doc from com.sun.org.apache.xpath.internal.Expression.deepEquals.

Compare this object with another object and see if they are equal, include the sub heararchy.

See Also
Expression#deepEquals(Expression)
executeback to summary
public XObject execute(XPathContext xctxt, int currentNode) throws TransformerException

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.execute.

Execute this pattern step, including predicates.

Parameters
xctxt:XPathContext

XPath runtime context.

currentNode:int

The current node context.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

Exceptions
TransformerException:

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

if a runtime exception occurs.

executeback to summary
public XObject execute(XPathContext xctxt) throws TransformerException

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.execute.

Execute this pattern step, including predicates.

Parameters
xctxt:XPathContext

XPath runtime context.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

Exceptions
TransformerException:

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

if a runtime exception occurs.

executeback to summary
public XObject execute(XPathContext xctxt, int currentNode, DTM dtm, int expType) throws TransformerException

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.execute.

Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters
xctxt:XPathContext

The XPath runtime context.

currentNode:int

The currentNode.

dtm:DTM

The DTM of the current node.

expType:int

The expanded type ID of the current node.

Returns:XObject

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

Exceptions
TransformerException:
if a runtime exception occurs.
executePredicatesback to summary
protected final boolean executePredicates(XPathContext xctxt, DTM dtm, int currentNode) throws TransformerException

Execute the predicates on this step to determine if the current node should be filtered or accepted.

Parameters
xctxt:XPathContext

The XPath runtime context.

dtm:DTM

The DTM of the current node.

currentNode:int

The current node context.

Returns:boolean

true if the node should be accepted, false otherwise.

executeRelativePathPatternback to summary
protected final XObject executeRelativePathPattern(XPathContext xctxt, DTM dtm, int currentNode) throws TransformerException

Execute the match pattern step relative to another step.

Parameters
xctxt:XPathContext

The XPath runtime context.

dtm:DTM

The DTM of the current node.

currentNode:int

The current node context.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

fixupVariablesback to summary
public void fixupVariables(List<QName> vars, int globalsSize)

Overrides com.sun.org.apache.xpath.internal.patterns.NodeTest.fixupVariables.

This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

Parameters
vars:List<QName>

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:int

The number of variables in the global variable area.

getAxisback to summary
public int getAxis()

Get the axis that this step follows.

Returns:int

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

getExpressionback to summary
public Expression getExpression()

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Doc from com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Get the raw Expression object that this class wraps.

See Also
ExpressionOwner#getExpression()
getLastPosback to summary
public int getLastPos(XPathContext xctxt)

Implements com.sun.org.apache.xpath.internal.axes.SubContextList.getLastPos.

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:XPathContext

XPath runtime context.

Returns:int

the count of the nodes that match the test.

getMatchScoreback to summary
public double getMatchScore(XPathContext xctxt, int context) throws TransformerException

Get the match score of the given node.

Parameters
xctxt:XPathContext

The XPath runtime context.

context:int

The node to be tested.

Returns:double

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

getPredicateback to summary
public Expression getPredicate(int i)

Get a predicate expression.

Parameters
i:int

The index of the predicate.

Returns:Expression

A predicate expression.

getPredicateCountback to summary
public final int getPredicateCount()

Get the number of predicates for this match pattern step.

Returns:int

the number of predicates for this match pattern step.

getPredicatesback to summary
public Expression[] getPredicates()

Set the list of predicate expressions for this pattern step.

Returns:Expression[]

List of expression objects.

getProximityPositionback to summary
private final int getProximityPosition(XPathContext xctxt, int predPos, boolean findLast)

Get the proximity position index of the current node based on this node test.

Parameters
xctxt:XPathContext

XPath runtime context.

predPos:int

Which predicate we're evaluating of foo[1][2][3].

findLast:boolean

If true, don't terminate when the context node is found.

Returns:int

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

getProximityPositionback to summary
public int getProximityPosition(XPathContext xctxt)

Implements com.sun.org.apache.xpath.internal.axes.SubContextList.getProximityPosition.

Get the proximity position index of the current node based on this node test.

Parameters
xctxt:XPathContext

XPath runtime context.

Returns:int

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

getRelativePathPatternback to summary
public StepPattern getRelativePathPattern()

Get the reference to nodetest and predicate for parent or ancestor.

Returns:StepPattern

The relative pattern expression.

getTargetStringback to summary
public String getTargetString()

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

Returns:String

local name or psuedo name of the node.

See Also
com.sun.org.apache.xpath.internal.compiler.PsuedoNames
setAxisback to summary
public void setAxis(int axis)

Set the axis that this step should follow.

Parameters
axis:int

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

setExpressionback to summary
public void setExpression(Expression exp)

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Doc from com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Set the raw expression object for this object.

See Also
ExpressionOwner#setExpression(Expression)
setPredicatesback to summary
public void setPredicates(Expression[] predicates)

Set the predicates for this match pattern step.

Parameters
predicates:Expression[]

An array of expressions that define predicates for this step.

setRelativePathPatternback to summary
public void setRelativePathPattern(StepPattern expr)

Set the reference to nodetest and predicate for parent or ancestor.

Parameters
expr:StepPattern

The relative pattern expression.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Get the string represenentation of this step for diagnostic purposes.

Returns:String

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

com.sun.org.apache.xpath.internal.patterns back to summary

pack-priv Class StepPattern.PredOwner

extends Object
implements ExpressionOwner
Class Inheritance
  • java.lang.Object
  • com.sun.org.apache.xpath.internal.patterns.StepPattern.PredOwner
All Implemented Interfaces
com.sun.org.apache.xpath.internal.ExpressionOwner

Field Summary

Modifier and TypeField and Description
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
PredOwner(int index)

Method Summary

Modifier and TypeMethod and Description
public Expression
getExpression()

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Get the raw Expression object that this class wraps.

public void
setExpression(Expression exp)

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Set the raw expression object for this object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_indexback to summary
pack-priv int m_index

Constructor Detail

PredOwnerback to summary
pack-priv PredOwner(int index)

Method Detail

getExpressionback to summary
public Expression getExpression()

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Doc from com.sun.org.apache.xpath.internal.ExpressionOwner.getExpression.

Get the raw Expression object that this class wraps.

See Also
ExpressionOwner#getExpression()
setExpressionback to summary
public void setExpression(Expression exp)

Implements com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Doc from com.sun.org.apache.xpath.internal.ExpressionOwner.setExpression.

Set the raw expression object for this object.

See Also
ExpressionOwner#setExpression(Expression)