Class NodeTest

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean m_isTotallyWild
      True if this test has a null namespace and a local name of WILD.
      protected java.lang.String m_name
      The local name to be tested for.
      (package private) java.lang.String m_namespace
      The namespace to be tested for, which may be null.
      (package private) XNumber m_score
      Statically calculated score for this test.
      protected int m_whatToShow
      This attribute determines which node types are accepted.
      static XNumber SCORE_NODETEST
      The match score if the pattern consists of just a NodeTest.
      static XNumber SCORE_NONE
      The match score if no match is made.
      static XNumber SCORE_NSWILD
      The match score if the pattern pattern has the form NCName:*.
      static XNumber SCORE_OTHER
      The match score if the pattern consists of something other than just a NodeTest or just a qname.
      static XNumber SCORE_QNAME
      The match score if the pattern has the form of a QName optionally preceded by an @ character.
      static int SHOW_BYFUNCTION
      Special bitmap for match patterns starting with a function.
      static java.lang.String WILD
      The namespace or local name for node tests with a wildcard.
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeTest()
      Null argument constructor.
      NodeTest​(int whatToShow)
      Construct an NodeTest that doesn't test for node names.
      NodeTest​(int whatToShow, java.lang.String namespace, java.lang.String name)
      Construct an NodeTest that tests for namespaces and node names.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void calcScore()
      Static calc of match score.
      void callVisitors​(XPathVisitor visitor)
      This will traverse the hierarchy, calling the visitor for each member.
      boolean deepEquals​(Expression expr)
      Compare this object with another object and see if they are equal, include the sub heararchy.
      XObject execute​(XPathContext xctxt)
      Execute an expression in the XPath runtime context, and return the result of the expression.
      XObject execute​(XPathContext xctxt, int context)
      Execute an expression in the XPath runtime context, and return the result of the expression.
      XObject execute​(XPathContext xctxt, int context, DTM dtm, int expType)
      Execute an expression in the XPath runtime context, and return the result of the expression.
      java.lang.String getLocalName()
      Return the local name to be tested.
      java.lang.String getNamespace()
      Return the namespace to be tested.
      static int getNodeTypeTest​(int whatToShow)
      Tell what node type to test, if not DTMFilter.SHOW_ALL.
      XNumber getStaticScore()
      Get the static score for this node test.
      int getWhatToShow()
      This attribute determines which node types are accepted.
      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.
      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.
      void setLocalName​(java.lang.String name)
      Set the local name to be tested.
      void setNamespace​(java.lang.String ns)
      Set the namespace to be tested.
      void setStaticScore​(XNumber score)
      Set the static score for this node test.
      void setWhatToShow​(int what)
      This attribute determines which node types are accepted.
      private static boolean subPartMatch​(java.lang.String p, java.lang.String t)
      Two names are equal if they and either both are null or the name t is wild and the name p is non-null, or the two strings are equal.
      private static boolean subPartMatchNS​(java.lang.String p, java.lang.String t)
      This is temporary to patch over Xerces issue with representing DOM namespaces as "".
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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)
        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.
      • 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.
      • calcScore

        protected void calcScore()
        Static calc of match score.
      • 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.
      • subPartMatch

        private static boolean subPartMatch​(java.lang.String p,
                                            java.lang.String t)
        Two names are equal if they and either both are null or the name t is wild and the name p is non-null, or the two strings are equal.
        Parameters:
        p - part string from the node.
        t - target string, which may be WILD.
        Returns:
        true if the strings match according to the rules of this method.
      • subPartMatchNS

        private static boolean subPartMatchNS​(java.lang.String p,
                                              java.lang.String t)
        This is temporary to patch over Xerces issue with representing DOM namespaces as "".
        Parameters:
        p - part string from the node, which may represent the null namespace as null or as "".
        t - target string, which may be WILD.
        Returns:
        true if the strings match according to the rules of this method.
      • execute

        public XObject execute​(XPathContext xctxt,
                               int context)
                        throws javax.xml.transform.TransformerException
        Execute an expression in the XPath runtime context, and return the result of the expression.
        Overrides:
        execute in class Expression
        Parameters:
        xctxt - The XPath runtime context.
        context - 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,
                               int context,
                               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 Expression
        Parameters:
        xctxt - The XPath runtime context.
        context - 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.
      • 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.
        Specified by:
        execute in class Expression
        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.
      • 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.
        Parameters:
        visitor - The visitor whose appropriate method will be called.