Package org.jaxen.function
Class SumFunction
- java.lang.Object
-
- org.jaxen.function.SumFunction
-
- All Implemented Interfaces:
Function
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.
- Author:
- bob mcwhirter (bob @ werken.com)
- See Also:
- Section 4.4 of the XPath Specification
-
-
Constructor Summary
Constructors Constructor Description SumFunction()
Create a newSumFunction
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
call
public java.lang.Object call(Context context, java.util.List args) throws FunctionCallException
Returns the sum of its arguments.- Specified by:
call
in interfaceFunction
- Parameters:
context
- the context at the point in the expression when the function is calledargs
- a list that contains exactly one item, also aList
- Returns:
- a
Double
containing the sum of the items inargs.get(0)
- Throws:
FunctionCallException
- ifargs
has more or less than one item; or if the first argument is not aList
-
evaluate
public static java.lang.Double evaluate(java.lang.Object obj, Navigator nav) throws FunctionCallException
Returns the sum of the items in a list. If necessary, each item in the list is first converted to aDouble
as if by the XPathnumber()
function.- Parameters:
obj
- aList
of numbers to be summednav
- ignored- Returns:
- the sum of the list
- Throws:
FunctionCallException
- ifobj
is not aList
-
-