org.apache.xpath.patterns

Class NodeTest

public class NodeTest extends Expression

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

UNKNOWN: advanced

Field Summary
static XNumberSCORE_NODETEST
The match score if the pattern consists of just a NodeTest.
static XNumberSCORE_NONE
The match score if no match is made.
static XNumberSCORE_NSWILD
The match score if the pattern pattern has the form NCName:*.
static XNumberSCORE_OTHER
The match score if the pattern consists of something other than just a NodeTest or just a qname.
static XNumberSCORE_QNAME
The match score if the pattern has the form of a QName optionally preceded by an @ character.
static intSHOW_BYFUNCTION
Special bitmap for match patterns starting with a function.
static StringSUPPORTS_PRE_STRIPPING
The URL to pass to the Node#supports method, to see if the DOM has already been stripped of whitespace nodes.
static StringWILD
The namespace or local name for node tests with a wildcard.
Constructor Summary
NodeTest(int whatToShow, String namespace, String name)
Construct an NodeTest that tests for namespaces and node names.
NodeTest(int whatToShow)
Construct an NodeTest that doesn't test for node names.
NodeTest()
Null argument constructor.
Method Summary
voidcallVisitors(ExpressionOwner owner, XPathVisitor visitor)
static voiddebugWhatToShow(int whatToShow)
Do a diagnostics dump of a whatToShow bit set.
booleandeepEquals(Expression expr)
XObjectexecute(XPathContext xctxt, int context)
Tell what the test score is for the given node.
XObjectexecute(XPathContext xctxt, int context, DTM dtm, int expType)
Tell what the test score is for the given node.
XObjectexecute(XPathContext xctxt)
Test the current node to see if it matches the given node test.
voidfixupVariables(Vector vars, int globalsSize)
Node tests by themselves do not need to fix up variables.
doublegetDefaultScore()
Get the score that this test will return if a test succeeds.
StringgetLocalName()
Return the local name to be tested.
StringgetNamespace()
Return the namespace to be tested.
static intgetNodeTypeTest(int whatToShow)
Tell what node type to test, if not DTMFilter.SHOW_ALL.
XNumbergetStaticScore()
Get the static score for this node test.
intgetWhatToShow()
This attribute determines which node types are accepted.
voidinitNodeTest(int whatToShow)
Initialize this node test by setting the whatToShow property, and calculating the score that this test will return if a test succeeds.
voidinitNodeTest(int whatToShow, String namespace, 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.
voidsetLocalName(String name)
Set the local name to be tested.
voidsetNamespace(String ns)
Set the namespace to be tested.
voidsetStaticScore(XNumber score)
Set the static score for this node test.
voidsetWhatToShow(int what)
This attribute determines which node types are accepted.

Field Detail

SCORE_NODETEST

public static final 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_NONE

public static final XNumber SCORE_NONE
The match score if no match is made.

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

SCORE_NSWILD

public static final 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_OTHER

public static final 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_QNAME

public static final 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

SHOW_BYFUNCTION

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

SUPPORTS_PRE_STRIPPING

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

WILD

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

See Also: the XPath NameTest production.

Constructor Detail

NodeTest

public NodeTest(int whatToShow, String namespace, String name)
Construct an NodeTest that tests for namespaces and node names.

Parameters: whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.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 {@link org.w3c.dom.traversal.NodeFilter}.

NodeTest

public NodeTest()
Null argument constructor.

Method Detail

callVisitors

public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)

See Also: XPathVisitable

debugWhatToShow

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

Parameters: whatToShow Bit set defined mainly by {@link org.apache.xml.dtm.DTMFilter}.

deepEquals

public boolean deepEquals(Expression expr)

See Also: deepEquals

execute

public XObject execute(XPathContext xctxt, int context)
Tell what the test score is for the given node.

Parameters: xctxt XPath runtime context. context The node being tested.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

execute

public XObject execute(XPathContext xctxt, int context, DTM dtm, int expType)
Tell what the test score is for the given node.

Parameters: xctxt XPath runtime context. context The node being tested.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

execute

public XObject execute(XPathContext xctxt)
Test the current node to see if it matches the given node test.

Parameters: xctxt XPath runtime context.

Returns: {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.

Throws: javax.xml.transform.TransformerException

fixupVariables

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

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.

getLocalName

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

Returns: the local name to be tested, or {@link #WILD}, or an empty string.

getNamespace

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

Returns: The namespace to be tested for, or {@link #WILD}, or null.

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 {@link org.apache.xml.dtm.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.

getStaticScore

public XNumber getStaticScore()
Get the static score for this node test.

Returns: Should be one of the SCORE_XXX constants.

getWhatToShow

public int getWhatToShow()
This attribute determines which node types are accepted. These constants are defined in the {@link org.w3c.dom.traversal.NodeFilter} interface.

Returns: bitset mainly defined in {@link org.w3c.dom.traversal.NodeFilter}.

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 {@link org.w3c.dom.traversal.NodeFilter}.

initNodeTest

public void initNodeTest(int whatToShow, String namespace, 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 {@link org.w3c.dom.traversal.NodeFilter}. namespace The namespace to be tested. name The local name to be tested.

setLocalName

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

Parameters: name the local name to be tested, or {@link #WILD}, or an empty string.

setNamespace

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

Parameters: ns The namespace to be tested for, or {@link #WILD}, or null.

setStaticScore

public void setStaticScore(XNumber score)
Set the static score for this node test.

Parameters: score Should be one of the SCORE_XXX constants.

setWhatToShow

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

Parameters: what bitset mainly defined in {@link org.w3c.dom.traversal.NodeFilter}.

Copyright © 2005 Apache XML Project. All Rights Reserved.