Class Aggregate

All Implemented Interfaces:
Serializable, SourceLocator, Container, Expression, InstructionInfoProvider

public class Aggregate extends SystemFunction
This class implements the sum(), avg(), count() functions,
See Also:
  • Field Details

  • Constructor Details

    • Aggregate

      public Aggregate()
  • Method Details

    • checkArguments

      public void checkArguments(StaticContext env) throws XPathException
      Static analysis: prevent sorting of the argument
      Overrides:
      checkArguments in class SystemFunction
      Throws:
      XPathException
    • getItemType

      public ItemType getItemType(TypeHierarchy th)
      Determine the item type of the value returned by the function
      Specified by:
      getItemType in interface Expression
      Overrides:
      getItemType in class SystemFunction
      Parameters:
      th -
      Returns:
      a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
    • evaluateItem

      public Item evaluateItem(XPathContext context) throws XPathException
      Evaluate the function
      Specified by:
      evaluateItem in interface Expression
      Overrides:
      evaluateItem in class ComputedExpression
      Parameters:
      context - The context in which the expression is to be evaluated
      Returns:
      the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • count

      public static int count(SequenceIterator iter) throws XPathException
      Get the number of items in a sequence identified by a SequenceIterator
      Parameters:
      iter - The SequenceIterator. This method moves the current position of the supplied iterator; if this isn't safe, make a copy of the iterator first by calling getAnother(). The supplied iterator must be positioned before the first item (there must have been no call on next()).
      Returns:
      the number of items in the underlying sequence
      Throws:
      XPathException - if a failure occurs reading the input sequence
    • isCountFunction

      public static boolean isCountFunction(Expression exp)
      Determine whether a given expression is a call to the count() function