org.jaxen.function

Class RoundFunction

public class RoundFunction extends Object implements Function

4.4 number round(number)

The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned. If the argument is NaN, then NaN is returned. If the argument is positive infinity, then positive infinity is returned. If the argument is negative infinity, then negative infinity is returned. If the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero, but greater than or equal to -0.5, then negative zero is returned.

Author: bob mcwhirter (bob @ werken.com)

See Also: Section 4.4 of the XPath Specification

Constructor Summary
RoundFunction()
Create a new RoundFunction object.
Method Summary
Objectcall(Context context, List args)
Returns the nearest integer to the number.
static Doubleevaluate(Object obj, Navigator nav)
Returns the integer nearest to the argument.

Constructor Detail

RoundFunction

public RoundFunction()
Create a new RoundFunction object.

Method Detail

call

public Object call(Context context, List args)
Returns the nearest integer to the number.

Parameters: context the context at the point in the expression when the function is called args a list with exactly one item which will be converted to a Double as if by the XPath number() function

Returns: a Double containing the integer nearest to args.get(0)

Throws: FunctionCallException if args has more or less than one item

evaluate

public static Double evaluate(Object obj, Navigator nav)
Returns the integer nearest to the argument. If necessary, the argument is first converted to a Double as if by the XPath number() function.

Parameters: obj the object to be rounded nav ignored

Returns: the integer nearest to obj