Class NodeTest
java.lang.Object
org.loboevolution.apache.xpath.Expression
org.loboevolution.apache.xpath.patterns.NodeTest
- All Implemented Interfaces:
SourceLocator
,ExpressionNode
,XPathVisitable
- Direct Known Subclasses:
PredicatedNodeTest
,StepPattern
This is the basic node test class for both match patterns and location path steps.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The local name to be tested for.protected int
This attribute determines which node types are accepted.static final XNumber
The match score if the pattern consists of just a NodeTest.static final XNumber
The match score if no match is made.static final XNumber
The match score if the pattern pattern has the form NCName:*.static final XNumber
The match score if the pattern consists of something other than just a NodeTest or just a qname.static final XNumber
The match score if the pattern has the form of a QName optionally preceded by an @ character.static final int
Special bitmap for match patterns starting with a function.static final String
The namespace or local name for node tests with a wildcard. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
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.execute
(XPathContext xctxt) Execute an expression in the XPath runtime context, and return the result of the expression.execute
(XPathContext xctxt, int context) Execute an expression in the XPath runtime context, and return the result of the expression.execute
(XPathContext xctxt, int context, DTM dtm, int expType) Execute an expression in the XPath runtime context, and return the result of the expression.Return the local name to be tested.Return the namespace to be tested.static int
getNodeTypeTest
(int whatToShow) Tell what node type to test, if not DTMFilter.SHOW_ALL.Get the static score for this node test.int
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, 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.void
setLocalName
(String name) Set the local name to be tested.void
setNamespace
(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.Methods inherited from class org.loboevolution.apache.xpath.Expression
asIterator, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isSameClass, isStableNumber, num
-
Field Details
-
WILD
The namespace or local name for node tests with a wildcard.- See Also:
-
m_whatToShow
protected int m_whatToShowThis attribute determines which node types are accepted. -
SHOW_BYFUNCTION
public static final int SHOW_BYFUNCTIONSpecial bitmap for match patterns starting with a function. Make sure this does not conflict withNodeFilter
.- See Also:
-
m_name
The local name to be tested for. -
SCORE_NODETEST
The match score if the pattern consists of just a NodeTest.- See Also:
-
SCORE_NSWILD
The match score if the pattern pattern has the form NCName:*.- See Also:
-
SCORE_QNAME
The match score if the pattern has the form of a QName optionally preceded by an @ character.- See Also:
-
SCORE_OTHER
The match score if the pattern consists of something other than just a NodeTest or just a qname.- See Also:
-
SCORE_NONE
The match score if no match is made.- See Also:
-
-
Constructor Details
-
NodeTest
Construct an NodeTest that tests for namespaces and node names.- Parameters:
whatToShow
- Bit set defined mainly byNodeFilter
.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 byNodeFilter
.
-
NodeTest
public NodeTest()Null argument constructor.
-
-
Method Details
-
getWhatToShow
public int getWhatToShow()This attribute determines which node types are accepted. These constants are defined in theNodeFilter
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 theNodeFilter
interface.- Parameters:
what
- bitset mainly defined inNodeFilter
.
-
getNamespace
Return the namespace to be tested.- Returns:
- The namespace to be tested for, or
WILD
, or null.
-
setNamespace
Set the namespace to be tested.- Parameters:
ns
- The namespace to be tested for, orWILD
, or null.
-
getLocalName
Return the local name to be tested.- Returns:
- the local name to be tested, or
WILD
, or an empty string.
-
setLocalName
Set the local name to be tested.- Parameters:
name
- the local name to be tested, orWILD
, or an empty string.
-
deepEquals
Compare this object with another object and see if they are equal, include the sub heararchy.- Specified by:
deepEquals
in classExpression
- 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 byNodeFilter
.
-
initNodeTest
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 byNodeFilter
.namespace
- The namespace to be tested.name
- The local name to be tested.
-
getStaticScore
Get the static score for this node test.- Returns:
- Should be one of the SCORE_XXX constants.
-
setStaticScore
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 byDTMFilter
.- 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.
-
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Overrides:
execute
in classExpression
- Parameters:
xctxt
- The XPath runtime context.context
- The currentNode.- Returns:
- The result of the expression in the form of a
XObject
. - Throws:
TransformerException
- if a runtime exception occurs.
-
execute
public XObject execute(XPathContext xctxt, int context, DTM dtm, int expType) throws TransformerException Execute an expression in the XPath runtime context, and return the result of the expression.- Overrides:
execute
in classExpression
- 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:
TransformerException
- if a runtime exception occurs.
-
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Specified by:
execute
in classExpression
- Parameters:
xctxt
- The XPath runtime context.- Returns:
- The result of the expression in the form of a
XObject
. - Throws:
TransformerException
- if a runtime exception occurs.
-
callVisitors
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.
-