Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jaxen.function
Class SumFunction

    java.lang.Object
      org.jaxen.function.SumFunction

All Implemented Interfaces:
  Function

public class SumFunction
extends 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
`SumFunction()` Create a new `SumFunction` object.

Method Summary
`Object` | `call(Context context, List args)` Returns the sum of its arguments.
`static Double` | `evaluate(Object obj, Navigator nav)` Returns the sum of the items in a list.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SumFunction

    public SumFunction()

  Create a new `SumFunction` object.

Method Detail

### call

    public Object call(Context context,
                       List args)
                throws FunctionCallException

  Returns the sum of its arguments.

  Specified by:
    `call` in interface `Function`
  Parameters:
    `context` - the context at the point in the expression when the function is called
    `args` - a list that contains exactly one item, also a `List`
  Returns:
    a `Double` containing the sum of the items in `args.get(0)`
  Throws:
    `FunctionCallException` - if `args` has more or less than one item; or if the first argument is not a `List`

### evaluate

    public static Double evaluate(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 a `Double` as if by the XPath `number()` function.

  Parameters:
    `obj` - a `List` of numbers to be summed
    `nav` - ignored
  Returns:
    the sum of the list
  Throws:
    `FunctionCallException` - if `obj` is not a `List`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 Codehaus. All Rights Reserved.