Class ForClause

java.lang.Object
net.sf.saxon.expr.flwor.Clause
net.sf.saxon.expr.flwor.ForClause

public class ForClause extends Clause
A "for" clause in a FLWOR expression
  • Constructor Details

    • ForClause

      public ForClause()
  • Method Details

    • getClauseKey

      public int getClauseKey()
      Description copied from class: Clause
      Get a keyword identifying what kind of clause this is
      Specified by:
      getClauseKey in class Clause
      Returns:
      the kind of clause
    • copy

      public ForClause copy()
      Description copied from class: Clause
      Create a copy of this clause
      Specified by:
      copy in class Clause
      Returns:
      the copied clause
    • setSequence

      public void setSequence(Expression sequence)
      Set the expression over which the "for" variable iterates
      Parameters:
      sequence - the expression over which the variable ranges
    • getSequence

      public Expression getSequence()
      Get the expression over which the "for" variable iterates
      Returns:
      the expression over which the variable ranges
    • setRangeVariable

      public void setRangeVariable(LocalVariableBinding binding)
      Set the range variable (the primary variable bound by this clause)
      Parameters:
      binding - the range variable
    • getRangeVariable

      public LocalVariableBinding getRangeVariable()
      Get the range variable (the primary variable bound by this clause)
      Returns:
      the range variable
    • setPositionVariable

      public void setPositionVariable(LocalVariableBinding binding)
      Set the position variable (the variable bound by the "at" clause)
      Parameters:
      binding - the position variable
    • getPositionVariable

      public LocalVariableBinding getPositionVariable()
      Get the position variable (the variable bound by the "at" clause)
      Returns:
      the position variable
    • getRangeVariables

      public LocalVariableBinding[] getRangeVariables()
      Get the number of variables bound by this clause
      Overrides:
      getRangeVariables in class Clause
      Returns:
      the number of variable bindings (1 or 2 depending on whether there is a position variable)
    • setAllowingEmpty

      public void setAllowingEmpty(boolean option)
      Say whether the "allowing empty" option is present
      Parameters:
      option - true if the "allowing empty" option is present
    • isAllowingEmpty

      public boolean isAllowingEmpty()
      Ask whether the "allowing empty" option is present
      Returns:
      true if the "allowing empty" option is present
    • typeCheck

      public void typeCheck(ExpressionVisitor visitor) throws XPathException
      Type-check the expression
      Overrides:
      typeCheck in class Clause
      Parameters:
      visitor - the ExpressionVisitor, providing access to static context information
      Throws:
      XPathException - if any error is detected
    • getPullStream

      public TuplePull getPullStream(TuplePull base, XPathContext context)
      Get a tuple stream that implements the functionality of this clause, taking its input from another tuple stream which this clause modifies
      Specified by:
      getPullStream in class Clause
      Parameters:
      base - the input tuple stream
      context - the XPath dynamic context
      Returns:
      the output tuple stream
    • getPushStream

      public TuplePush getPushStream(TuplePush destination, XPathContext context)
      Get a push-mode tuple stream that implements the functionality of this clause, supplying its output to another tuple stream
      Specified by:
      getPushStream in class Clause
      Parameters:
      destination - the output tuple stream
      context - the dynamic evaluation context
      Returns:
      the push tuple stream that implements the functionality of this clause of the FLWOR expression
    • addPredicate

      public boolean addPredicate(FLWORExpression flwor, ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType, Expression condition) throws XPathException
      Convert where clause to a predicate.
      Parameters:
      visitor - the expression visitor
      contextItemType - the item type of the context item
      condition - the predicate to be added. This will always be a single term (never a composite condition using "and"), as the where clause is split into separate terms before calling this method
      Returns:
      true if the expression has been changed, that is, if the where clause has been converted
      Throws:
      XPathException - if an error is encountered
    • processSubExpressions

      public void processSubExpressions(ExpressionProcessor processor) throws XPathException
      Process the subexpressions of this clause
      Specified by:
      processSubExpressions in class Clause
      Parameters:
      processor - the expression processor used to process the subexpressions
      Throws:
      XPathException - if any error is detected
    • gatherVariableReferences

      public void gatherVariableReferences(List references)
    • gatherVariableReferences

      public void gatherVariableReferences(ExpressionVisitor visitor, Binding binding, List<VariableReference> references)
      Description copied from class: Clause
      Build a list of all references to a variables declared in this clause
      Overrides:
      gatherVariableReferences in class Clause
      Parameters:
      visitor - the expression visitor
      binding - a variable declared in this clause
      references - the list of variable references, initially empty, to which the method will append
    • refineVariableType

      public void refineVariableType(ExpressionVisitor visitor, List<VariableReference> references, Expression returnExpr)
      Description copied from class: Clause
      Supply improved type information to the expressions that contain references to the variables declared in this clause
      Overrides:
      refineVariableType in class Clause
      Parameters:
      visitor - the expression visitor
      references - the list of variable references
      returnExpr - the expression in the return clause
    • explain

      public void explain(ExpressionPresenter out)
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
      explain in class Clause
      Parameters:
      out - the expression presenter used to display the structure
    • toString

      public String toString()
      Overrides:
      toString in class Object