Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xpath.patterns
Class NodeTest  view NodeTest download NodeTest.java

java.lang.Object
  extended byorg.apache.xpath.Expression
      extended byorg.apache.xpath.patterns.NodeTest
All Implemented Interfaces:
org.apache.xpath.ExpressionNode, java.io.Serializable, javax.xml.transform.SourceLocator, org.apache.xpath.XPathVisitable
Direct Known Subclasses:
StepPattern

public class NodeTest
extends org.apache.xpath.Expression

This is the basic node test class for both match patterns and location path steps.


Field Summary
private  boolean m_isTotallyWild
          True if this test has a null namespace and a local name of WILD 55 .
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)  org.apache.xpath.objects.XNumber m_score
          Statically calculated score for this test.
protected  int m_whatToShow
          This attribute determines which node types are accepted.
static org.apache.xpath.objects.XNumber SCORE_NODETEST
          The match score if the pattern consists of just a NodeTest.
static org.apache.xpath.objects.XNumber SCORE_NONE
          The match score if no match is made.
static org.apache.xpath.objects.XNumber SCORE_NSWILD
          The match score if the pattern pattern has the form NCName:*.
static org.apache.xpath.objects.XNumber SCORE_OTHER
          The match score if the pattern consists of something other than just a NodeTest or just a qname.
static org.apache.xpath.objects.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 SUPPORTS_PRE_STRIPPING
          The URL to pass to the Node#supports method, to see if the DOM has already been stripped of whitespace nodes.
static java.lang.String WILD
          The namespace or local name for node tests with a wildcard.
 
Fields inherited from class org.apache.xpath.Expression
 
Constructor Summary
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
protected  void calcScore()
          Static calc of match score.
 void callVisitors(org.apache.xpath.ExpressionOwner owner, org.apache.xpath.XPathVisitor visitor)
          This will traverse the heararchy, calling the visitor for each member.
static void debugWhatToShow(int whatToShow)
          Do a diagnostics dump of a whatToShow bit set.
 boolean deepEquals(org.apache.xpath.Expression expr)
          Compare this object with another object and see if they are equal, include the sub heararchy.
 org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt)
          Test the current node to see if it matches the given node test.
 org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt, int context)
          Tell what the test score is for the given node.
 org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt, int context, org.apache.xml.dtm.DTM dtm, int expType)
          Tell what the test score is for the given node.
 void fixupVariables(java.util.Vector vars, int globalsSize)
          Node tests by themselves do not need to fix up variables.
 double getDefaultScore()
          Get the score that this test will return if a test succeeds.
 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.
 org.apache.xpath.objects.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(org.apache.xpath.objects.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 org.apache.xpath.Expression
asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isSameClass, isStableNumber, num, warn, xstr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WILD

public static final java.lang.String WILD
The namespace or local name for node tests with a wildcard.

See Also:
the XPath NameTest production., Constant Field Values

SUPPORTS_PRE_STRIPPING

public static final java.lang.String SUPPORTS_PRE_STRIPPING
The URL to pass to the Node#supports method, to see if the DOM has already been stripped of whitespace nodes.

See Also:
Constant Field Values

m_whatToShow

protected int m_whatToShow
This attribute determines which node types are accepted.


SHOW_BYFUNCTION

public static final int SHOW_BYFUNCTION
Special bitmap for match patterns starting with a function. Make sure this does not conflict with org.w3c.dom.traversal.NodeFilter.

See Also:
Constant Field Values

m_namespace

java.lang.String m_namespace
The namespace to be tested for, which may be null.


m_name

protected java.lang.String m_name
The local name to be tested for.


m_score

org.apache.xpath.objects.XNumber m_score
Statically calculated score for this test. One of SCORE_NODETEST 55 , SCORE_NONE 55 , SCORE_NSWILD 55 , SCORE_QNAME 55 , or SCORE_OTHER 55 .


SCORE_NODETEST

public static final org.apache.xpath.objects.XNumber SCORE_NODETEST
The match score if the pattern consists of just a NodeTest.

See Also:
XSLT Specification - 5.5 Conflict Resolution for Template Rules

SCORE_NSWILD

public static final org.apache.xpath.objects.XNumber SCORE_NSWILD
The match score if the pattern pattern has the form NCName:*.

See Also:
XSLT Specification - 5.5 Conflict Resolution for Template Rules

SCORE_QNAME

public static final org.apache.xpath.objects.XNumber SCORE_QNAME
The match score if the pattern has the form of a QName optionally preceded by an @ character.

See Also:
XSLT Specification - 5.5 Conflict Resolution for Template Rules

SCORE_OTHER

public static final org.apache.xpath.objects.XNumber SCORE_OTHER
The match score if the pattern consists of something other than just a NodeTest or just a qname.

See Also:
XSLT Specification - 5.5 Conflict Resolution for Template Rules

SCORE_NONE

public static final org.apache.xpath.objects.XNumber SCORE_NONE
The match score if no match is made.

See Also:
XSLT Specification - 5.5 Conflict Resolution for Template Rules

m_isTotallyWild

private boolean m_isTotallyWild
True if this test has a null namespace and a local name of WILD 55 .

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.


NodeTest

public NodeTest(int whatToShow)
Construct an NodeTest that doesn't test for node names.


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 org.w3c.dom.traversal.NodeFilter interface.


setWhatToShow

public void setWhatToShow(int what)
This attribute determines which node types are accepted. These constants are defined in the org.w3c.dom.traversal.NodeFilter interface.


getNamespace

public java.lang.String getNamespace()
Return the namespace to be tested.


setNamespace

public void setNamespace(java.lang.String ns)
Set the namespace to be tested.


getLocalName

public java.lang.String getLocalName()
Return the local name to be tested.


setLocalName

public void setLocalName(java.lang.String name)
Set the local name to be tested.


deepEquals

public boolean deepEquals(org.apache.xpath.Expression expr)
Description copied from class: org.apache.xpath.Expression
Compare this object with another object and see if they are equal, include the sub heararchy.


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.


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.


getStaticScore

public org.apache.xpath.objects.XNumber getStaticScore()
Get the static score for this node test.


setStaticScore

public void setStaticScore(org.apache.xpath.objects.XNumber score)
Set the static score for this node test.


calcScore

protected void calcScore()
Static calc of match score.


getDefaultScore

public double getDefaultScore()
Get 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.


debugWhatToShow

public static void debugWhatToShow(int whatToShow)
Do a diagnostics dump of a whatToShow bit set.


subPartMatch

private static final 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.


subPartMatchNS

private static final boolean subPartMatchNS(java.lang.String p,
                                            java.lang.String t)
This is temporary to patch over Xerces issue with representing DOM namespaces as "".


execute

public org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt,
                                                int context)
                                         throws javax.xml.transform.TransformerException
Tell what the test score is for the given node.


execute

public org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt,
                                                int context,
                                                org.apache.xml.dtm.DTM dtm,
                                                int expType)
                                         throws javax.xml.transform.TransformerException
Tell what the test score is for the given node.


execute

public org.apache.xpath.objects.XObject execute(org.apache.xpath.XPathContext xctxt)
                                         throws javax.xml.transform.TransformerException
Test the current node to see if it matches the given node test.


fixupVariables

public void fixupVariables(java.util.Vector vars,
                           int globalsSize)
Node tests by themselves do not need to fix up variables.


callVisitors

public void callVisitors(org.apache.xpath.ExpressionOwner owner,
                         org.apache.xpath.XPathVisitor visitor)
Description copied from interface: org.apache.xpath.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.