Class StepPattern
java.lang.Object
org.loboevolution.apache.xpath.Expression
org.loboevolution.apache.xpath.patterns.NodeTest
org.loboevolution.apache.xpath.patterns.StepPattern
- All Implemented Interfaces:
SourceLocator
,SubContextList
,ExpressionNode
,XPathVisitable
- Direct Known Subclasses:
ContextMatchStepPattern
,FunctionPattern
This class represents a single pattern match step.
-
Field Summary
Fields inherited from class org.loboevolution.apache.xpath.patterns.NodeTest
m_name, m_whatToShow, SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, WILD
-
Constructor Summary
ConstructorDescriptionStepPattern
(int whatToShow, int axis) Construct a StepPattern that doesn't test for node names.StepPattern
(int whatToShow, String namespace, String name, int axis) Construct a StepPattern that tests for namespaces and node names. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Static calc of match score.void
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.void
callVisitors
(XPathVisitor visitor) This will traverse the hierarchy, calling the visitor for each member.boolean
Tell if this expression or it's subexpressions can traverse outside the current subtree.boolean
deepEquals
(Expression expr) Compare this object with another object and see if they are equal, include the sub heararchy.execute
(XPathContext xctxt) Execute an expression in the XPath runtime context, and return the result of the expression.execute
(XPathContext xctxt, int currentNode) Execute an expression in the XPath runtime context, and return the result of the expression.execute
(XPathContext xctxt, int currentNode, DTM dtm, int expType) Execute an expression in the XPath runtime context, and return the result of the expression.protected final boolean
executePredicates
(XPathContext xctxt, DTM dtm, int currentNode) Execute the predicates on this step to determine if the current node should be filtered or accepted.protected final XObject
executeRelativePathPattern
(XPathContext xctxt, DTM dtm, int currentNode) Execute the match pattern step relative to another step.int
getAxis()
Get the axis that this step follows.int
getLastPos
(XPathContext xctxt) Get the number of nodes in the node list, which, in the XSLT 1 based counting system, is the last index position.getPredicate
(int i) Get a predicate expression.final int
Get the number of predicates for this match pattern step.Set the list of predicate expressions for this pattern step.int
getProximityPosition
(XPathContext xctxt) Get the current sub-context position.Get the reference to nodetest and predicate for parent or ancestor.void
setAxis
(int axis) Set the axis that this step should follow.void
setPredicates
(Expression[] predicates) Set the predicates for this match pattern step.void
Set the reference to nodetest and predicate for parent or ancestor.toString()
Methods inherited from class org.loboevolution.apache.xpath.patterns.NodeTest
getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShow
Methods inherited from class org.loboevolution.apache.xpath.Expression
asIterator, asNode, assertion, bool, error, execute, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isSameClass, isStableNumber, num
-
Field Details
-
m_axis
protected int m_axisThe axis for this test.
-
-
Constructor Details
-
StepPattern
Construct a StepPattern that tests for namespaces and node names.- Parameters:
whatToShow
- Bit set defined mainly byNodeFilter
.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.
-
StepPattern
public StepPattern(int whatToShow, int axis) Construct a StepPattern that doesn't test for node names.- Parameters:
whatToShow
- Bit set defined mainly byNodeFilter
.axis
- The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
-
-
Method Details
-
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:
-
setRelativePathPattern
Set the reference to nodetest and predicate for parent or ancestor.- Parameters:
expr
- The relative pattern expression.
-
getRelativePathPattern
Get the reference to nodetest and predicate for parent or ancestor.- Returns:
- The relative pattern expression.
-
getPredicates
Set the list of predicate expressions for this pattern step.- Returns:
- List of expression objects.
-
canTraverseOutsideSubtree
public boolean canTraverseOutsideSubtree()Tell if this expression or it's subexpressions can traverse outside the current subtree.- Overrides:
canTraverseOutsideSubtree
in classExpression
- Returns:
- true if traversal outside the context node's subtree can occur.
-
getPredicate
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.
-
setPredicates
Set the predicates for this match pattern step.- Parameters:
predicates
- An array of expressions that define predicates for this step.
-
calcScore
public void calcScore()Static calc of match score. -
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Overrides:
execute
in classNodeTest
- Parameters:
xctxt
- The XPath runtime context.currentNode
- The currentNode.- Returns:
- The result of the expression in the form of a
XObject
. - Throws:
TransformerException
- if a runtime exception occurs.
-
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Overrides:
execute
in classNodeTest
- Parameters:
xctxt
- The XPath runtime context.- Returns:
- The result of the expression in the form of a
XObject
. - Throws:
TransformerException
- if a runtime exception occurs.
-
execute
public XObject execute(XPathContext xctxt, int currentNode, DTM dtm, int expType) throws TransformerException Execute an expression in the XPath runtime context, and return the result of the expression.- Overrides:
execute
in classNodeTest
- 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:
TransformerException
- if a runtime exception occurs.
-
getProximityPosition
Get the current sub-context position.- Specified by:
getProximityPosition
in interfaceSubContextList
- Parameters:
xctxt
- The XPath runtime context.- Returns:
- The position of the current node in the list.
-
getLastPos
Get the number of nodes in the node list, which, in the XSLT 1 based counting system, is the last index position.- Specified by:
getLastPos
in interfaceSubContextList
- Parameters:
xctxt
- The XPath runtime context.- Returns:
- the number of nodes in the node list.
-
executeRelativePathPattern
protected final XObject executeRelativePathPattern(XPathContext xctxt, DTM dtm, int currentNode) throws TransformerException Execute the match pattern step relative to another step.- Parameters:
xctxt
- The XPath runtime context.dtm
- The DTM of the current node.currentNode
- The current node context.- Returns:
NodeTest.SCORE_NODETEST
,NodeTest.SCORE_NONE
,NodeTest.SCORE_NSWILD
,NodeTest.SCORE_QNAME
, orNodeTest.SCORE_OTHER
.- Throws:
TransformerException
- in case of error
-
executePredicates
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
- The XPath runtime context.dtm
- The DTM of the current node.currentNode
- The current node context.- Returns:
- true if the node should be accepted, false otherwise.
- Throws:
TransformerException
- in case of error
-
toString
-
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.
-
getAxis
public int getAxis()Get the axis that this step follows.- Returns:
- The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
-
callVisitors
This will traverse the hierarchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Specified by:
callVisitors
in interfaceXPathVisitable
- Overrides:
callVisitors
in classNodeTest
- Parameters:
visitor
- The visitor whose appropriate method will be called.
-
callSubtreeVisitors
Call the visitors on the subtree. Factored out from callVisitors so it may be called by derived classes. -
deepEquals
Compare this object with another object and see if they are equal, include the sub heararchy.- Overrides:
deepEquals
in 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.
-