Class StepPattern

    • Field Detail

      • m_axis

        protected int m_axis
        The axis for this test.
      • m_targetString

        java.lang.String m_targetString
        The target local name or psuedo name, for hash table lookup optimization.
      • m_relativePathPattern

        StepPattern m_relativePathPattern
        Reference to nodetest and predicate for parent or ancestor.
      • m_predicates

        Expression[] m_predicates
        The list of predicate expressions for this pattern step.
    • Constructor Detail

      • StepPattern

        public StepPattern​(int whatToShow,
                           java.lang.String namespace,
                           java.lang.String name,
                           int axis)
        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.
      • StepPattern

        public StepPattern​(int whatToShow,
                           int axis)
        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.
    • 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:
        PseudoNames
      • 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:
        Array of expression objects.
      • canTraverseOutsideSubtree

        public boolean canTraverseOutsideSubtree()
        Tell if this expression or it's subexpressions can traverse outside the current subtree.
        Overrides:
        canTraverseOutsideSubtree in class Expression
        Returns:
        true if traversal outside the context node's subtree can occur.
      • 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 an expression in the XPath runtime context, and return the result of the expression.
        Overrides:
        execute in class NodeTest
        Parameters:
        xctxt - The XPath runtime context.
        currentNode - The currentNode.
        Returns:
        The result of the expression in the form of a XObject.
        Throws:
        javax.xml.transform.TransformerException - if a runtime exception occurs.
      • execute

        public XObject execute​(XPathContext xctxt)
                        throws javax.xml.transform.TransformerException
        Execute an expression in the XPath runtime context, and return the result of the expression.
        Overrides:
        execute in class NodeTest
        Parameters:
        xctxt - The XPath runtime context.
        Returns:
        The result of the expression in the form of a XObject.
        Throws:
        javax.xml.transform.TransformerException - if a runtime exception occurs.
      • execute

        public XObject execute​(XPathContext xctxt,
                               int currentNode,
                               DTM dtm,
                               int expType)
                        throws javax.xml.transform.TransformerException
        Execute an expression in the XPath runtime context, and return the result of the expression.
        Overrides:
        execute in class NodeTest
        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.
      • checkProximityPosition

        private 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 - The XPath runtime context.
        predPos - Which predicate we're evaluating of foo[1][2][3].
        dtm - The DTM of the current node.
        context - The currentNode.
        pos - The position being requested, i.e. the value returned by m_predicates[predPos].execute(xctxt).
        Returns:
        true of the position of the context matches pos, false otherwise.
      • getProximityPosition

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

        public int getProximityPosition​(XPathContext xctxt)
        Get the current sub-context position.
        Specified by:
        getProximityPosition in interface SubContextList
        Parameters:
        xctxt - The XPath runtime context.
        Returns:
        The position of the current node in the list.
      • getLastPos

        public 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.
        Specified by:
        getLastPos in interface SubContextList
        Parameters:
        xctxt - The XPath runtime context.
        Returns:
        the number of nodes in the node list.
      • executePredicates

        protected final boolean executePredicates​(XPathContext xctxt,
                                                  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 - in case of error
      • toString

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

        public void callVisitors​(XPathVisitor visitor)
        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 interface XPathVisitable
        Overrides:
        callVisitors in class NodeTest
        Parameters:
        visitor - The visitor whose appropriate method will be called.
      • callSubtreeVisitors

        protected void callSubtreeVisitors​(XPathVisitor visitor)
        Call the visitors on the subtree. Factored out from callVisitors so it may be called by derived classes.
      • deepEquals

        public boolean deepEquals​(Expression expr)
        Compare this object with another object and see if they are equal, include the sub heararchy.
        Overrides:
        deepEquals in class NodeTest
        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.