Class NodeTest

    • Constructor Detail

      • NodeTest

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

        public NodeTest​(int whatToShow)
        Construct an NodeTest that doesn't test for node names.
        Parameters:
        whatToShow - Bit set defined mainly by NodeFilter.
      • NodeTest

        public NodeTest()
        Null argument constructor.
    • Method Detail

      • getWhatToShow

        public int getWhatToShow()
        This attribute determines which node types are accepted. These constants are defined in the NodeFilter interface.
        Returns:
        bitset mainly defined in NodeFilter.
      • setWhatToShow

        public void setWhatToShow​(int what)
        This attribute determines which node types are accepted. These constants are defined in the NodeFilter interface.
        Parameters:
        what - bitset mainly defined in NodeFilter.
      • getNamespace

        public java.lang.String getNamespace()
        Return the namespace to be tested.
        Returns:
        The namespace to be tested for, or WILD, or null.
      • setNamespace

        public void setNamespace​(java.lang.String ns)
        Set the namespace to be tested.
        Parameters:
        ns - The namespace to be tested for, or WILD, or null.
      • getLocalName

        public java.lang.String getLocalName()
        Return the local name to be tested.
        Returns:
        the local name to be tested, or WILD, or an empty string.
      • setLocalName

        public void setLocalName​(java.lang.String name)
        Set the local name to be tested.
        Parameters:
        name - the local name to be tested, or WILD, or an empty string.
      • deepEquals

        public boolean deepEquals​(Expression expr)
        Description copied from class: Expression
        Compare this object with another object and see if they are equal, include the sub heararchy.
        Specified by:
        deepEquals in class Expression
        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.
        See Also:
        Expression.deepEquals(Expression)
      • initNodeTest

        public void initNodeTest​(int whatToShow)
        Initialize this node test by setting the whatToShow property, and calculating the score that this test will return if a test succeeds.
        Parameters:
        whatToShow - Bit set defined mainly by NodeFilter.
      • initNodeTest

        public void initNodeTest​(int whatToShow,
                                 java.lang.String namespace,
                                 java.lang.String name)
        Initialize this node test by setting the whatToShow property and the namespace and local name, and calculating the score that this test will return if a test succeeds.
        Parameters:
        whatToShow - Bit set defined mainly by NodeFilter.
        namespace - The namespace to be tested.
        name - The local name to be tested.
      • getStaticScore

        public XNumber getStaticScore()
        Get the static score for this node test.
        Returns:
        Should be one of the SCORE_XXX constants.
      • setStaticScore

        public void setStaticScore​(XNumber score)
        Set the static score for this node test.
        Parameters:
        score - Should be one of the SCORE_XXX constants.
      • getDefaultScore

        public double getDefaultScore()
        Get the score that this test will return if a test succeeds.
        Returns:
        the score that this test will return if a test succeeds.
      • getNodeTypeTest

        public static int getNodeTypeTest​(int whatToShow)
        Tell what node type to test, if not DTMFilter.SHOW_ALL.
        Parameters:
        whatToShow - Bit set defined mainly by DTMFilter.
        Returns:
        the node type for the whatToShow. Since whatToShow can specify multiple types, it will return the first bit tested that is on, so the caller of this function should take care that this is the function they really want to call. If none of the known bits are set, this function will return zero.
      • debugWhatToShow

        public static void debugWhatToShow​(int whatToShow)
        Do a diagnostics dump of a whatToShow bit set.
        Parameters:
        whatToShow - Bit set defined mainly by DTMFilter.
      • execute

        public XObject execute​(XPathContext xctxt,
                               int context,
                               DTM dtm,
                               int expType)
                        throws javax.xml.transform.TransformerException
        Tell what the test score is for the given node.
        Overrides:
        execute in class Expression
        Parameters:
        xctxt - XPath runtime context.
        context - The node being tested.
        dtm - The DTM of the current node.
        expType - The expanded type ID of the current node.
        Returns:
        SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_QNAME, or SCORE_OTHER.
        Throws:
        javax.xml.transform.TransformerException
      • fixupVariables

        public void fixupVariables​(java.util.Vector vars,
                                   int globalsSize)
        Node tests by themselves do not need to fix up variables.
        Specified by:
        fixupVariables in class Expression
        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). NEEDSDOC @param globalsSize
      • callVisitors

        public void callVisitors​(ExpressionOwner owner,
                                 XPathVisitor visitor)
        Description copied from interface: XPathVisitable
        This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.
        Parameters:
        owner - The owner of the visitor, where that path may be rewritten if needed.
        visitor - The visitor whose appropriate method will be called.
        See Also:
        XPathVisitable.callVisitors(ExpressionOwner, XPathVisitor)