|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xpath.Expression org.apache.xpath.patterns.NodeTest
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 . |
protected String |
m_name
The local name to be tested for. |
(package private) 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 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 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,
String namespace,
String name)
Construct an NodeTest that tests for namespaces and node names. |
Method Summary | |
protected void |
calcScore()
Static calc of match score. |
void |
callVisitors(ExpressionOwner owner,
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(Expression expr)
Compare this object with another object and see if they are equal, include the sub heararchy. |
XObject |
execute(XPathContext xctxt)
Test the current node to see if it matches the given node test. |
XObject |
execute(XPathContext xctxt,
int context)
Tell what the test score is for the given node. |
XObject |
execute(XPathContext xctxt,
int context,
DTM dtm,
int expType)
Tell what the test score is for the given node. |
void |
fixupVariables(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. |
String |
getLocalName()
Return the local name to be tested. |
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,
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. |
private static 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. |
private static boolean |
subPartMatchNS(String p,
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 |
public static final String WILD
public static final String SUPPORTS_PRE_STRIPPING
protected int m_whatToShow
public static final int SHOW_BYFUNCTION
NodeFilter
.
String m_namespace
protected String m_name
XNumber m_score
SCORE_NODETEST
,
SCORE_NONE
,
SCORE_NSWILD
,
SCORE_QNAME
, or
SCORE_OTHER
.
public static final XNumber SCORE_NODETEST
public static final XNumber SCORE_NSWILD
public static final XNumber SCORE_QNAME
public static final XNumber SCORE_OTHER
public static final XNumber SCORE_NONE
private boolean m_isTotallyWild
WILD
.
Constructor Detail |
public NodeTest(int whatToShow, String namespace, String name)
whatToShow
- Bit set defined mainly by NodeFilter
.namespace
- The namespace to be tested.name
- The local name to be tested.public NodeTest(int whatToShow)
whatToShow
- Bit set defined mainly by NodeFilter
.public NodeTest()
Method Detail |
public int getWhatToShow()
NodeFilter
interface.
NodeFilter
.public void setWhatToShow(int what)
NodeFilter
interface.
what
- bitset mainly defined in NodeFilter
.public String getNamespace()
WILD
, or null.public void setNamespace(String ns)
ns
- The namespace to be tested for, or WILD
, or null.public String getLocalName()
WILD
, or an empty string.public void setLocalName(String name)
name
- the local name to be tested, or WILD
, or an empty string.public boolean deepEquals(Expression expr)
Expression
deepEquals
in class Expression
expr
- Another expression object.
Expression.deepEquals(Expression)
public void initNodeTest(int whatToShow)
whatToShow
- Bit set defined mainly by NodeFilter
.public void initNodeTest(int whatToShow, String namespace, String name)
whatToShow
- Bit set defined mainly by NodeFilter
.namespace
- The namespace to be tested.name
- The local name to be tested.public XNumber getStaticScore()
public void setStaticScore(XNumber score)
score
- Should be one of the SCORE_XXX constants.protected void calcScore()
public double getDefaultScore()
public static int getNodeTypeTest(int whatToShow)
whatToShow
- Bit set defined mainly by
DTMFilter
.
public static void debugWhatToShow(int whatToShow)
whatToShow
- Bit set defined mainly by
DTMFilter
.private static final boolean subPartMatch(String p, String t)
p
- part string from the node.t
- target string, which may be WILD
.
private static final boolean subPartMatchNS(String p, String t)
p
- part string from the node, which may represent the null namespace
as null or as "".t
- target string, which may be WILD
.
public XObject execute(XPathContext xctxt, int context) throws javax.xml.transform.TransformerException
execute
in class Expression
xctxt
- XPath runtime context.context
- The node being tested.
SCORE_NODETEST
,
SCORE_NONE
,
SCORE_NSWILD
,
SCORE_QNAME
, or
SCORE_OTHER
.
javax.xml.transform.TransformerException
public XObject execute(XPathContext xctxt, int context, DTM dtm, int expType) throws javax.xml.transform.TransformerException
execute
in class Expression
xctxt
- XPath runtime context.context
- The node being tested.dtm
- The DTM of the current node.expType
- The expanded type ID of the current node.
SCORE_NODETEST
,
SCORE_NONE
,
SCORE_NSWILD
,
SCORE_QNAME
, or
SCORE_OTHER
.
javax.xml.transform.TransformerException
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
execute
in class Expression
xctxt
- XPath runtime context.
SCORE_NODETEST
,
SCORE_NONE
,
SCORE_NSWILD
,
SCORE_QNAME
, or
SCORE_OTHER
.
javax.xml.transform.TransformerException
public void fixupVariables(Vector vars, int globalsSize)
fixupVariables
in class Expression
vars
- 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 globalsSizepublic void callVisitors(ExpressionOwner owner, XPathVisitor visitor)
XPathVisitable
owner
- The owner of the visitor, where that path may be
rewritten if needed.visitor
- The visitor whose appropriate method will be called.XPathVisitable#callVisitors(ExpressionOwner, XPathVisitor)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |