BEA Systems, Inc.


weblogic.apache.xpath.patterns
Class StepPattern

java.lang.Object
  |
  +--weblogic.apache.xpath.Expression
        |
        +--weblogic.apache.xpath.patterns.NodeTest
              |
              +--weblogic.apache.xpath.patterns.StepPattern
Direct Known Subclasses:
ContextMatchStepPattern, FunctionPattern

public class StepPattern
extends NodeTest
implements SubContextList

This class represents a single pattern match step.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

See Also:
Serialized Form

Field Summary
protected  int m_axis
          The axis for this test.
 
Fields inherited from class weblogic.apache.xpath.patterns.NodeTest
m_name, m_whatToShow, SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, SUPPORTS_PRE_STRIPPING, WILD
 
Fields inherited from class weblogic.apache.xpath.Expression
m_slocator
 
Constructor Summary
StepPattern(int whatToShow, int axis, int axisForPredicate)
          Construct a StepPattern that doesn't test for node names.
StepPattern(int whatToShow, java.lang.String namespace, java.lang.String name, int axis, int axisForPredicate)
          Construct a StepPattern that tests for namespaces and node names.
 
Method Summary
 void calcScore()
          Static calc of match score.
 void calcTargetString()
          Calculate the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.
 boolean canTraverseOutsideSubtree()
          Tell if this expression or it's subexpressions can traverse outside the current subtree.
 XObject execute(XPathContext xctxt)
          Execute this pattern step, including predicates.
 XObject execute(XPathContext xctxt, int currentNode)
          Execute this pattern step, including predicates.
 XObject execute(XPathContext xctxt, int currentNode, weblogic.apache.xml.dtm.DTM dtm, int expType)
          Execute an expression in the XPath runtime context, and return the result of the expression.
protected  boolean executePredicates(XPathContext xctxt, weblogic.apache.xml.dtm.DTM dtm, int currentNode)
          Execute the predicates on this step to determine if the current node should be filtered or accepted.
protected  XObject executeRelativePathPattern(XPathContext xctxt, weblogic.apache.xml.dtm.DTM dtm, int currentNode)
          Execute the match pattern step relative to another step.
 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 getAxis()
          Get the axis that this step follows.
 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.
 double getMatchScore(XPathContext xctxt, int context)
          Get the match score of the given node.
 Expression getPredicate(int i)
          Get a predicate expression.
 int getPredicateCount()
          Get the number of predicates for this match pattern step.
 Expression[] getPredicates()
          Set the list of predicate expressions for this pattern step.
 int getProximityPosition(XPathContext xctxt)
          Get the proximity position index of the current node based on this node test.
 StepPattern getRelativePathPattern()
          Get the reference to nodetest and predicate for parent or ancestor.
 java.lang.String getTargetString()
          Get the local name or psuedo name of the node that this pattern will test, for hash table lookup optimization.
 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 setRelativePathPattern(StepPattern expr)
          Set the reference to nodetest and predicate for parent or ancestor.
 java.lang.String toString()
          Get the string represenentation of this step for diagnostic purposes.
 
Methods inherited from class weblogic.apache.xpath.patterns.NodeTest
debugWhatToShow, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShow
 
Methods inherited from class weblogic.apache.xpath.Expression
asIterator, asNode, assertion, bool, error, executeCharsToContentHandler, isNodesetExpr, isStableNumber, num, setSourceLocator, warn, xstr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_axis

protected int m_axis
The axis for this test.
Constructor Detail

StepPattern

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

Parameters:
whatToShow - Bit set defined mainly by 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 NodeFilter.
axis - The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
axisForPredicate - No longer used.
Method Detail

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

getTargetString

public java.lang.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

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.

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.
Overrides:
fixupVariables in class NodeTest

setRelativePathPattern

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

Parameters:
expr - The relative pattern expression.

getRelativePathPattern

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

Returns:
The relative pattern expression.

getPredicates

public 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. NOTE: Ancestors tests with predicates are problematic, and will require special treatment.

Returns:
true if traversal outside the context node's subtree can occur.
Overrides:
canTraverseOutsideSubtree in class Expression

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.

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.

calcScore

public void calcScore()
Static calc of match score.

Overrides:
calcScore in class NodeTest

execute

public XObject execute(XPathContext xctxt,
                       int currentNode)
                throws javax.xml.transform.TransformerException
Execute this pattern step, including predicates.

Parameters:
xctxt - XPath runtime context.
currentNode - The current node context.
Returns:
NodeTest.SCORE_NODETEST, NodeTest.SCORE_NONE, NodeTest.SCORE_NSWILD, NodeTest.SCORE_QNAME, or NodeTest.SCORE_OTHER.
Throws:
javax.xml.transform.TransformerException -  
Overrides:
execute in class NodeTest

execute

public XObject execute(XPathContext xctxt)
                throws javax.xml.transform.TransformerException
Execute this pattern step, including predicates.

Parameters:
xctxt - XPath runtime context.
Returns:
NodeTest.SCORE_NODETEST, NodeTest.SCORE_NONE, NodeTest.SCORE_NSWILD, NodeTest.SCORE_QNAME, or NodeTest.SCORE_OTHER.
Throws:
javax.xml.transform.TransformerException -  
Overrides:
execute in class NodeTest

execute

public XObject execute(XPathContext xctxt,
                       int currentNode,
                       weblogic.apache.xml.dtm.DTM dtm,
                       int expType)
                throws javax.xml.transform.TransformerException
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.
Overrides:
execute in class NodeTest

getProximityPosition

public int getProximityPosition(XPathContext xctxt)
Get the proximity position index of the current node based on this node test.
Specified by:
getProximityPosition in interface SubContextList

Parameters:
xctxt - XPath runtime context.
Returns:
the proximity position index of the current node based on the node test.

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.
Specified by:
getLastPos in interface SubContextList

Parameters:
xctxt - XPath runtime context.
Returns:
the count of the nodes that match the test.

executeRelativePathPattern

protected final XObject executeRelativePathPattern(XPathContext xctxt,
                                                   weblogic.apache.xml.dtm.DTM dtm,
                                                   int currentNode)
                                            throws javax.xml.transform.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, or NodeTest.SCORE_OTHER.
Throws:
javax.xml.transform.TransformerException -  

executePredicates

protected final boolean executePredicates(XPathContext xctxt,
                                          weblogic.apache.xml.dtm.DTM dtm,
                                          int currentNode)
                                   throws javax.xml.transform.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:
javax.xml.transform.TransformerException -  

toString

public java.lang.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.
Overrides:
toString in class java.lang.Object

getMatchScore

public double getMatchScore(XPathContext xctxt,
                            int context)
                     throws javax.xml.transform.TransformerException
Get the match score of the given node.

Parameters:
xctxt - The XPath runtime context.
context - The node to be tested.
Returns:
NodeTest.SCORE_NODETEST, NodeTest.SCORE_NONE, NodeTest.SCORE_NSWILD, NodeTest.SCORE_QNAME, or NodeTest.SCORE_OTHER.
Throws:
javax.xml.transform.TransformerException -  

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.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs70

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference