public class SumFunction extends java.lang.Object implements Function
4.4 number sum(node-set)
The sum function returns the sum, for each node in the argument node-set, of the result of converting the string-values of the node to a number.
Constructor and Description |
---|
SumFunction()
Create a new
SumFunction object. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
call(Context context,
java.util.List args)
Returns the sum of its arguments.
|
static java.lang.Double |
evaluate(java.lang.Object obj,
Navigator nav)
Returns the sum of the items in a list.
|
public java.lang.Object call(Context context, java.util.List args) throws FunctionCallException
call
in interface Function
context
- the context at the point in the
expression when the function is calledargs
- a list that contains exactly one item, also a List
Double
containing the sum of the items in args.get(0)
FunctionCallException
- if args
has more or less than one item;
or if the first argument is not a List
public static java.lang.Double evaluate(java.lang.Object obj, Navigator nav) throws FunctionCallException
Double
as if by the XPath number()
function.obj
- a List
of numbers to be summednav
- ignoredFunctionCallException
- if obj
is not a List