net.sf.saxon.functions.Aggregate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of saxon-he Show documentation
Show all versions of saxon-he Show documentation
An OSGi bundle for Saxon-HE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Saxonica Limited.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package net.sf.saxon.functions;
import net.sf.saxon.expr.parser.ExpressionTool;
import net.sf.saxon.expr.parser.ExpressionVisitor;
import net.sf.saxon.expr.parser.Optimizer;
import net.sf.saxon.trans.XPathException;
/**
* This abstract class provides functionality common to the sum(), avg(), count(),
* exists(), and empty() functions. These all take a sequence as input and produce a singleton
* as output; and they are all independent of the ordering of the items in the input.
*/
public abstract class Aggregate extends SystemFunctionCall {
/**
* Static analysis: prevent sorting of the argument
*/
public void checkArguments(/*@NotNull*/ ExpressionVisitor visitor) throws XPathException {
super.checkArguments(visitor);
Optimizer opt = visitor.getConfiguration().obtainOptimizer();
argument[0] = ExpressionTool.unsorted(opt, argument[0], true);
// we don't care about the order of the results, but we do care about how many nodes there are
}
}