org.jaxen.function

Class NumberFunction

Implemented Interfaces:
Function

public class NumberFunction
extends java.lang.Object
implements Function

4.4 number number(object)

The number function converts its argument to a number as follows:

If the argument is omitted, it defaults to a node-set with the context node as its only member.

NOTE: The number function should not be used for conversion of numeric data occurring in an element in an XML document unless the element is of a type that represents numeric data in a language-neutral format (which would typically be transformed into a language-specific format for presentation to a user). In addition, the number function cannot be used unless the language-neutral format used by the element is consistent with the XPath syntax for a Number.
Author:
bob mcwhirter (bob @ werken.com)
See Also:
Section 4.4 of the XPath Specification

Field Summary

private static Double
NaN

Constructor Summary

NumberFunction()
Create a new NumberFunction object.

Method Summary

Object
call(Context context, List args)
Returns the number value of args.get(0), or the number value of the context node if args is empty.
static Double
evaluate(Object obj, Navigator nav)
Returns the number value of obj.
static boolean
isNaN(Double val)
Determines whether the argument is not a number (NaN) as defined by IEEE 754.
static boolean
isNaN(double val)
Determines whether the argument is not a number (NaN) as defined by IEEE 754.

Field Details

NaN

private static final Double NaN

Constructor Details

NumberFunction

public NumberFunction()
Create a new NumberFunction object.

Method Details

call

public Object call(Context context,
                   List args)
            throws FunctionCallException
Returns the number value of args.get(0), or the number value of the context node if args is empty.
Specified by:
call in interface Function
Parameters:
context - the context at the point in the expression when the function is called
args - a list containing the single item to be converted to a Double
Returns:
a Double
Throws:
FunctionCallException - if args has more than one item

evaluate

public static Double evaluate(Object obj,
                              Navigator nav)
Returns the number value of obj.
Parameters:
obj - the object to be converted to a number
nav - the Navigator used to calculate the string-value of node-sets
Returns:
a Double

isNaN

public static boolean isNaN(Double val)
Determines whether the argument is not a number (NaN) as defined by IEEE 754.
Parameters:
val - the Double to test
Returns:
true if the value is NaN, false otherwise

isNaN

public static boolean isNaN(double val)
Determines whether the argument is not a number (NaN) as defined by IEEE 754.
Parameters:
val - the double to test
Returns:
true if the value is NaN, false otherwise