Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal.patterns

public Class NodeTest

extends Expression
Class Inheritance
Known Direct Subclasses
com.sun.org.apache.xpath.internal.patterns.StepPattern, com.sun.org.apache.xpath.internal.axes.PredicatedNodeTest
Imports
com.sun.org.apache.xml.internal.dtm.DTM, .DTMFilter, com.sun.org.apache.xml.internal.utils.QName, com.sun.org.apache.xpath.internal.Expression, .ExpressionOwner, .XPath, .XPathContext, .XPathVisitor, com.sun.org.apache.xpath.internal.objects.XNumber, .XObject, java.util.ArrayList, .List

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

Field Summary

Modifier and TypeField and Description
private boolean
m_isTotallyWild

True if this test has a null namespace and a local name of WILD.

protected String
m_name

The local name to be tested for.

pack-priv String
m_namespace

The namespace to be tested for, which may be null.

pack-priv XNumber
m_score

Statically calculated score for this test.

protected int
m_whatToShow

This attribute determines which node types are accepted.

public static final XNumber
SCORE_NODETEST

The match score if the pattern consists of just a NodeTest.

public static final XNumber
SCORE_NONE

The match score if no match is made.

public static final XNumber
SCORE_NSWILD

The match score if the pattern pattern has the form NCName:*.

public static final XNumber
SCORE_OTHER

The match score if the pattern consists of something other than just a NodeTest or just a qname.

public static final XNumber
SCORE_QNAME

The match score if the pattern has the form of a QName optionally preceded by an @ character.

pack-priv static final long
public static final int
SHOW_BYFUNCTION

Special bitmap for match patterns starting with a function.

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.

public static final String
WILD

The namespace or local name for node tests with a wildcard.

Constructor Summary

AccessConstructor and Description
public
NodeTest(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
,
String
The namespace to be tested.
namespace
,
String
The local name to be tested.
name
)

Construct an NodeTest that tests for namespaces and node names.

public
NodeTest(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
)

Construct an NodeTest that doesn't test for node names.

public
NodeTest()

Null argument constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
calcScore()

Static calc of match score.

public void
callVisitors(ExpressionOwner
The owner of the visitor, where that path may be rewritten if needed.
owner
,
XPathVisitor
The visitor whose appropriate method will be called.
visitor
)

Implements com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

This will traverse the heararchy, calling the visitor for each member.

public static void
debugWhatToShow(int whatToShow)

Do a diagnostics dump of a whatToShow bit set.

public boolean
deepEquals(Expression
Another expression object.
expr
)

Implements abstract com.sun.org.apache.xpath.internal.Expression.deepEquals.

Compare this object with another object and see if they are equal, include the sub heararchy.

public XObject
public XObject
public XObject
public void
fixupVariables(List<QName>
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
vars
,
int globalsSize)

Implements abstract com.sun.org.apache.xpath.internal.Expression.fixupVariables.

Node tests by themselves do not need to fix up variables.

public double

Returns:

the score that this test will return if a test succeeds.
getDefaultScore
()

Get the score that this test will return if a test succeeds.

public String

Returns:

the local name to be tested, or WILD, or an empty string.
getLocalName
()

Return the local name to be tested.

public String

Returns:

The namespace to be tested for, or WILD, or null.
getNamespace
()

Return the namespace to be tested.

public static int

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.
getNodeTypeTest
(int whatToShow)

Tell what node type to test, if not DTMFilter.SHOW_ALL.

public XNumber

Returns:

Should be one of the SCORE_XXX constants.
getStaticScore
()

Get the static score for this node test.

public int

Returns:

bitset mainly defined in org.w3c.dom.traversal.NodeFilter.
getWhatToShow
()

This attribute determines which node types are accepted.

public void
initNodeTest(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
)

Initialize this node test by setting the whatToShow property, and calculating the score that this test will return if a test succeeds.

public void
initNodeTest(int
Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.
whatToShow
,
String
The namespace to be tested.
namespace
,
String
The local name to be tested.
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.

public void
setLocalName(String
the local name to be tested, or WILD, or an empty string.
name
)

Set the local name to be tested.

public void
setNamespace(String
The namespace to be tested for, or WILD, or null.
ns
)

Set the namespace to be tested.

public void
setStaticScore(XNumber
Should be one of the SCORE_XXX constants.
score
)

Set the static score for this node test.

public void
setWhatToShow(int
bitset mainly defined in org.w3c.dom.traversal.NodeFilter.
what
)

This attribute determines which node types are accepted.

private static final boolean

Returns:

true if the strings match according to the rules of this method.
subPartMatch
(String
part string from the node.
p
,
String
target string, which may be WILD.
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 final boolean

Returns:

true if the strings match according to the rules of this method.
subPartMatchNS
(String
part string from the node, which may represent the null namespace as null or as "".
p
,
String
target string, which may be WILD.
t
)

This is temporary to patch over Xerces issue with representing DOM namespaces as "".

Inherited from com.sun.org.apache.xpath.internal.Expression:
asIteratorasIteratorRawasNodeassertionboolcanTraverseOutsideSubtreeerrorexecuteexecuteCharsToContentHandlerexprAddChildexprGetChildexprGetNumChildrenexprGetParentexprSetParentgetColumnNumbergetExpressionOwnergetLineNumbergetPublicIdgetSystemIdisNodesetExprisSameClassisStableNumbernumwarnxstr

Field Detail

m_isTotallyWildback to summary
private boolean m_isTotallyWild

True if this test has a null namespace and a local name of WILD.

m_nameback to summary
protected String m_name

The local name to be tested for.

m_namespaceback to summary
pack-priv String m_namespace

The namespace to be tested for, which may be null.

m_scoreback to summary
pack-priv XNumber m_score

Statically calculated score for this test. One of SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_QNAME, or SCORE_OTHER.

m_whatToShowback to summary
protected int m_whatToShow

This attribute determines which node types are accepted.

SCORE_NODETESTback to summary
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_NONEback to summary
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_NSWILDback to summary
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_OTHERback to summary
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_QNAMEback to summary
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
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides com.sun.org.apache.xpath.internal.Expression.serialVersionUID.

SHOW_BYFUNCTIONback to summary
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.

SUPPORTS_PRE_STRIPPINGback to summary
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.

WILDback to summary
public static final String WILD

The namespace or local name for node tests with a wildcard.

See Also
the XPath NameTest production.

Constructor Detail

NodeTestback to summary
public NodeTest(int whatToShow, String namespace, String name)

Construct an NodeTest that tests for namespaces and node names.

Parameters
whatToShow:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

namespace:String

The namespace to be tested.

name:String

The local name to be tested.

NodeTestback to summary
public NodeTest(int whatToShow)

Construct an NodeTest that doesn't test for node names.

Parameters
whatToShow:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

NodeTestback to summary
public NodeTest()

Null argument constructor.

Method Detail

calcScoreback to summary
protected void calcScore()

Static calc of match score.

callVisitorsback to summary
public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)

Implements com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

Doc from com.sun.org.apache.xpath.internal.XPathVisitable.callVisitors.

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:ExpressionOwner

The owner of the visitor, where that path may be rewritten if needed.

visitor:XPathVisitor

The visitor whose appropriate method will be called.

See Also
com.sun.org.apache.xpath.internal.XPathVisitable#callVisitors(ExpressionOwner, XPathVisitor)
debugWhatToShowback to summary
public static void debugWhatToShow(int whatToShow)

Do a diagnostics dump of a whatToShow bit set.

Parameters
whatToShow:int

Bit set defined mainly by com.sun.org.apache.xml.internal.dtm.DTMFilter.

deepEqualsback to summary
public boolean deepEquals(Expression expr)

Implements abstract com.sun.org.apache.xpath.internal.Expression.deepEquals.

Doc from com.sun.org.apache.xpath.internal.Expression.deepEquals.

Compare this object with another object and see if they are equal, include the sub heararchy.

Parameters
expr:Expression

Another expression object.

Returns:boolean

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)
executeback to summary
public XObject execute(XPathContext xctxt, int context) throws TransformerException

Overrides com.sun.org.apache.xpath.internal.Expression.execute.

Tell what the test score is for the given node.

Parameters
xctxt:XPathContext

XPath runtime context.

context:int

The node being tested.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

Exceptions
TransformerException:

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

if a runtime exception occurs.

executeback to summary
public XObject execute(XPathContext xctxt, int context, DTM dtm, int expType) throws TransformerException

Overrides com.sun.org.apache.xpath.internal.Expression.execute.

Tell what the test score is for the given node.

Parameters
xctxt:XPathContext

XPath runtime context.

context:int

The node being tested.

dtm:DTM

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

The DTM of the current node.

expType:int

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

The expanded type ID of the current node.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

Exceptions
TransformerException:

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

if a runtime exception occurs.

executeback to summary
public XObject execute(XPathContext xctxt) throws TransformerException

Implements abstract com.sun.org.apache.xpath.internal.Expression.execute.

Test the current node to see if it matches the given node test.

Parameters
xctxt:XPathContext

XPath runtime context.

Returns:XObject

com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD, com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME, or com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER.

Exceptions
TransformerException:

Doc from com.sun.org.apache.xpath.internal.Expression.execute.

if a runtime exception occurs.

fixupVariablesback to summary
public void fixupVariables(List<QName> vars, int globalsSize)

Implements abstract com.sun.org.apache.xpath.internal.Expression.fixupVariables.

Node tests by themselves do not need to fix up variables.

Parameters
vars:List<QName>

Doc from com.sun.org.apache.xpath.internal.Expression.fixupVariables.

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

getDefaultScoreback to summary
public double getDefaultScore()

Get the score that this test will return if a test succeeds.

Returns:double

the score that this test will return if a test succeeds.

getLocalNameback to summary
public String getLocalName()

Return the local name to be tested.

Returns:String

the local name to be tested, or WILD, or an empty string.

getNamespaceback to summary
public String getNamespace()

Return the namespace to be tested.

Returns:String

The namespace to be tested for, or WILD, or null.

getNodeTypeTestback to summary
public static int getNodeTypeTest(int whatToShow)

Tell what node type to test, if not DTMFilter.SHOW_ALL.

Parameters
whatToShow:int

Bit set defined mainly by com.sun.org.apache.xml.internal.dtm.DTMFilter.

Returns:int

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.

getStaticScoreback to summary
public XNumber getStaticScore()

Get the static score for this node test.

Returns:XNumber

Should be one of the SCORE_XXX constants.

getWhatToShowback to summary
public int getWhatToShow()

This attribute determines which node types are accepted. These constants are defined in the org.w3c.dom.traversal.NodeFilter interface.

Returns:int

bitset mainly defined in org.w3c.dom.traversal.NodeFilter.

initNodeTestback to summary
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:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

initNodeTestback to summary
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:int

Bit set defined mainly by org.w3c.dom.traversal.NodeFilter.

namespace:String

The namespace to be tested.

name:String

The local name to be tested.

setLocalNameback to summary
public void setLocalName(String name)

Set the local name to be tested.

Parameters
name:String

the local name to be tested, or WILD, or an empty string.

setNamespaceback to summary
public void setNamespace(String ns)

Set the namespace to be tested.

Parameters
ns:String

The namespace to be tested for, or WILD, or null.

setStaticScoreback to summary
public void setStaticScore(XNumber score)

Set the static score for this node test.

Parameters
score:XNumber

Should be one of the SCORE_XXX constants.

setWhatToShowback to summary
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.

Parameters
what:int

bitset mainly defined in org.w3c.dom.traversal.NodeFilter.

subPartMatchback to summary
private static final boolean subPartMatch(String p, 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:String

part string from the node.

t:String

target string, which may be WILD.

Returns:boolean

true if the strings match according to the rules of this method.

subPartMatchNSback to summary
private static final boolean subPartMatchNS(String p, String t)

This is temporary to patch over Xerces issue with representing DOM namespaces as "".

Parameters
p:String

part string from the node, which may represent the null namespace as null or as "".

t:String

target string, which may be WILD.

Returns:boolean

true if the strings match according to the rules of this method.