HasPositionalPredCheckerpublic class HasPositionalPredChecker extends XPathVisitor
Fields Summary |
---|
private boolean | m_hasPositionalPred | private int | m_predDepth |
Methods Summary |
---|
public static boolean | check(com.sun.org.apache.xpath.internal.axes.LocPathIterator path)Process the LocPathIterator to see if it contains variables
or functions that may make it context dependent.
HasPositionalPredChecker hppc = new HasPositionalPredChecker();
path.callVisitors(null, hppc);
return hppc.m_hasPositionalPred;
| public boolean | visitFunction(com.sun.org.apache.xpath.internal.ExpressionOwner owner, com.sun.org.apache.xpath.internal.functions.Function func)Visit a function.
if((func instanceof FuncPosition) ||
(func instanceof FuncLast))
m_hasPositionalPred = true;
return true;
| public boolean | visitPredicate(com.sun.org.apache.xpath.internal.ExpressionOwner owner, com.sun.org.apache.xpath.internal.Expression pred)Visit a predicate within a location path. Note that there isn't a
proper unique component for predicates, and that the expression will
be called also for whatever type Expression is.
m_predDepth++;
if(m_predDepth == 1)
{
if((pred instanceof Variable) ||
(pred instanceof XNumber) ||
(pred instanceof Div) ||
(pred instanceof Plus) ||
(pred instanceof Minus) ||
(pred instanceof Mod) ||
(pred instanceof Quo) ||
(pred instanceof Mult) ||
(pred instanceof com.sun.org.apache.xpath.internal.operations.Number) ||
(pred instanceof Function))
m_hasPositionalPred = true;
else
pred.callVisitors(owner, this);
}
m_predDepth--;
// Don't go have the caller go any further down the subtree.
return false;
|
|