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

FilterExprIteratorSimple

public class FilterExprIteratorSimple extends LocPathIterator
Class to use for one-step iteration that doesn't have a predicate, and doesn't need to set the context.

Fields Summary
private Expression
m_expr
The contained expression. Should be non-null.
private transient XNodeSet
m_exprObj
The result of executing m_expr. Needs to be deep cloned on clone op.
private boolean
m_mustHardReset
private boolean
m_canDetachNodeset
Constructors Summary
public FilterExprIteratorSimple()
Create a ChildTestIterator object.

param
traverser Traverser that tells how the KeyIterator is to be handled.
throws
javax.xml.transform.TransformerException


                       
   
  
    super(null);
  
public FilterExprIteratorSimple(Expression expr)
Create a ChildTestIterator object.

param
traverser Traverser that tells how the KeyIterator is to be handled.
throws
javax.xml.transform.TransformerException

    super(null);
    m_expr = expr;
  
Methods Summary
public voidcallPredicateVisitors(com.sun.org.apache.xpath.internal.XPathVisitor visitor)
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.

param
owner The owner of the visitor, where that path may be rewritten if needed.
param
visitor The visitor whose appropriate method will be called.

    m_expr.callVisitors(new filterExprOwner(), visitor);

    super.callPredicateVisitors(visitor);
  
public booleandeepEquals(com.sun.org.apache.xpath.internal.Expression expr)

see
Expression#deepEquals(Expression)

    if (!super.deepEquals(expr))
      return false;

    FilterExprIteratorSimple fet = (FilterExprIteratorSimple) expr;
    if (!m_expr.deepEquals(fet.m_expr))
      return false;

    return true;
  
public voiddetach()
Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.

  
    if(m_allowDetach)
    {
  		super.detach();
  		m_exprObj.detach();
  		m_exprObj = null;
    }
  
public static com.sun.org.apache.xpath.internal.objects.XNodeSetexecuteFilterExpr(int context, com.sun.org.apache.xpath.internal.XPathContext xctxt, com.sun.org.apache.xml.internal.utils.PrefixResolver prefixResolver, boolean isTopLevel, int stackFrame, com.sun.org.apache.xpath.internal.Expression expr)
Execute the expression. Meant for reuse by other FilterExpr iterators that are not derived from this object.

    PrefixResolver savedResolver = xctxt.getNamespaceContext();
    XNodeSet result = null;

    try
    {
      xctxt.pushCurrentNode(context);
      xctxt.setNamespaceContext(prefixResolver);

      // The setRoot operation can take place with a reset operation, 
      // and so we may not be in the context of LocPathIterator#nextNode, 
      // so we have to set up the variable context, execute the expression, 
      // and then restore the variable context.

      if (isTopLevel)
      {
        // System.out.println("calling m_expr.execute(getXPathContext())");
        VariableStack vars = xctxt.getVarStack();

        // These three statements need to be combined into one operation.
        int savedStart = vars.getStackFrame();
        vars.setStackFrame(stackFrame);

        result = (com.sun.org.apache.xpath.internal.objects.XNodeSet) expr.execute(xctxt);
        result.setShouldCacheNodes(true);

        // These two statements need to be combined into one operation.
        vars.setStackFrame(savedStart);
      }
      else
          result = (com.sun.org.apache.xpath.internal.objects.XNodeSet) expr.execute(xctxt);

    }
    catch (javax.xml.transform.TransformerException se)
    {

      // TODO: Fix...
      throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(se);
    }
    finally
    {
      xctxt.popCurrentNode();
      xctxt.setNamespaceContext(savedResolver);
    }
    return result;
  
public voidfixupVariables(java.util.Vector vars, int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

param
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).

    super.fixupVariables(vars, globalsSize);
    m_expr.fixupVariables(vars, globalsSize);
  
public intgetAnalysisBits()
Get the analysis bits for this walker, as defined in the WalkerFactory.

return
One of WalkerFactory#BIT_DESCENDANT, etc.

    if (null != m_expr && m_expr instanceof PathComponent)
    {
      return ((PathComponent) m_expr).getAnalysisBits();
    }
    return WalkerFactory.BIT_FILTER;
  
public intgetAxis()
Returns the axis being iterated, if it is known.

return
Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.

  	if(null != m_exprObj)
    	return m_exprObj.getAxis();
    else
    	return Axis.FILTEREDLIST;
  
public com.sun.org.apache.xpath.internal.ExpressiongetInnerExpression()
Get the inner contained expression of this filter.

    return m_expr;
  
public booleanisDocOrdered()
Returns true if all the nodes in the iteration well be returned in document order. Warning: This can only be called after setRoot has been called!

return
true as a default.

    return m_exprObj.isDocOrdered();
  
public intnextNode()
Returns the next node in the set and advances the position of the iterator in the set. After a NodeIterator is created, the first call to nextNode() returns the first node in the set.

return
The next Node in the set being iterated over, or null if there are no more members in that set.

  	if(m_foundLast)
  		return DTM.NULL;

    int next;

    if (null != m_exprObj)
    {
      m_lastFetched = next = m_exprObj.nextNode();
    }
    else
      m_lastFetched = next = DTM.NULL;

    // m_lastFetched = next;
    if (DTM.NULL != next)
    {
      m_pos++;
      return next;
    }
    else
    {
      m_foundLast = true;

      return DTM.NULL;
    }
  
public voidsetInnerExpression(com.sun.org.apache.xpath.internal.Expression expr)
Set the inner contained expression of this filter.

    expr.exprSetParent(this);
    m_expr = expr;
  
public voidsetRoot(int context, java.lang.Object environment)
Initialize the context values for this expression after it is cloned.

param
execContext The XPath runtime context for this transformation.

  	super.setRoot(context, environment);
  	m_exprObj = executeFilterExpr(context, m_execContext, getPrefixResolver(), 
  	                  getIsTopLevel(), m_stackFrame, m_expr);