Class OperandArray

java.lang.Object
net.sf.saxon.expr.oper.OperandArray
All Implemented Interfaces:
Iterable<Operand>

public class OperandArray extends Object implements Iterable<Operand>
Defines an operand set comprising an array of operands numbered zero to N. All operands must be present. Typically (but not exclusively) used for the arguments of a function call. The operands may all have the same operand roles, or have different operand roles.
  • Constructor Details

  • Method Details

    • iterator

      public Iterator<Operand> iterator()
      Returns an iterator over elements of type T.
      Specified by:
      iterator in interface Iterable<Operand>
      Returns:
      an Iterator.
    • copy

      public Operand[] copy()
    • getRoles

      public OperandRole[] getRoles()
      Get the operand roles
      Returns:
      the roles of the operands as an array, one per operand
    • getOperand

      public Operand getOperand(int n)
      Get the operand whose identifying number is n.
      Parameters:
      n - the identifier of the operand (counting from zero)
      Returns:
      the operand, or null in the case of an optional operand that is absent in the case of this particular expression
      Throws:
      IllegalArgumentException - if there cannot be an operand at this position
    • getOperandExpression

      public Expression getOperandExpression(int n)
      Get the child expression associated with the operand whose identifying number is n.
      Parameters:
      n - the identifier of the operand
      Returns:
      the expression associated with the operand, or null in the case of an optional operand that is absent in the case of this particular expression
      Throws:
      IllegalArgumentException - if there cannot be an operand at this position
    • operands

      public Iterable<Operand> operands()
      Return a collection containing all the operands. Generally there is a significance to the order of operands, which usually reflects the order in the raw textual expression.
      Returns:
      the collection of operands
    • operandExpressions

      public Iterable<Expression> operandExpressions()
    • setOperand

      public void setOperand(int n, Expression child)
      Set the value of the operand with integer n. The method should implement a fast path for the case where the operand has not actually been changed.
      Parameters:
      n - identifies the expression to be set/replaced
      child - the new subexpression
      Throws:
      IllegalArgumentException - if the value of n identifies no operand
    • getNumberOfOperands

      public int getNumberOfOperands()
      Get the number of operands in the operand array
      Returns:
      the number of operands
    • every

      public static <T> boolean every(T[] args, Predicate<T> condition)
      Utility method (doesn't really belong here) to test if every element of an array satisfies some condition
      Type Parameters:
      T - the type of the items in the array
      Parameters:
      args - the array
      condition - the condition
      Returns:
      true if the condition is true for every item in the array
    • some

      public static <T> boolean some(T[] args, Predicate<T> condition)
      Utility method (doesn't really belong here) to test if some element of an array satisfies some condition
      Type Parameters:
      T - the type of the items in the array
      Parameters:
      args - the array
      condition - the condition
      Returns:
      true if the condition is true for every item in the array