FileDocCategorySizeDatePackage
HasPositionalPredChecker.javaAPI DocJava SE 5 API4299Fri Aug 26 14:56:06 BST 2005com.sun.org.apache.xpath.internal.axes

HasPositionalPredChecker

public class HasPositionalPredChecker extends XPathVisitor

Fields Summary
private boolean
m_hasPositionalPred
private int
m_predDepth
Constructors Summary
Methods Summary
public static booleancheck(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.

param
path LocPathIterator that is assumed to be absolute, but needs checking.
return
true if the path is confirmed to be absolute, false if it may contain context dependencies.

	
	                                                	 
	    
	
		HasPositionalPredChecker hppc = new HasPositionalPredChecker();
		path.callVisitors(null, hppc);
		return hppc.m_hasPositionalPred;
	
public booleanvisitFunction(com.sun.org.apache.xpath.internal.ExpressionOwner owner, com.sun.org.apache.xpath.internal.functions.Function func)
Visit a function.

param
owner The owner of the expression, to which the expression can be reset if rewriting takes place.
param
func The function reference object.
return
true if the sub expressions should be traversed.

		if((func instanceof FuncPosition) ||
		   (func instanceof FuncLast))
			m_hasPositionalPred = true;
		return true;
	
public booleanvisitPredicate(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.

param
owner The owner of the expression, to which the expression can be reset if rewriting takes place.
param
pred The predicate object.
return
true if the sub expressions should be traversed.

    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;