Package org.jaxen.function
Class BooleanFunction
- java.lang.Object
-
- org.jaxen.function.BooleanFunction
-
- All Implemented Interfaces:
Function
public class BooleanFunction extends java.lang.Object implements Function
4.3
boolean boolean(object)
The boolean function converts its argument to a boolean as follows:
-
a number is true if and only if it is neither positive or negative zero nor NaN
-
a node-set is true if and only if it is non-empty
-
a string is true if and only if its length is non-zero
-
an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type
- Author:
- bob mcwhirter (bob @ werken.com)
- See Also:
- Section 4.3 of the XPath Specification
-
-
Constructor Summary
Constructors Constructor Description BooleanFunction()
Create a newBooleanFunction
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)
Convert the argument to aBoolean
static java.lang.Boolean
evaluate(java.lang.Object obj, Navigator nav)
Convert the argumentobj
to aBoolean
according to the following rules:
-
-
-
Method Detail
-
call
public java.lang.Object call(Context context, java.util.List args) throws FunctionCallException
Convert the argument to aBoolean
- Specified by:
call
in interfaceFunction
- Parameters:
context
- the context at the point in the expression when the function is calledargs
- a list with exactly one item which will be converted to aBoolean
- Returns:
- the result of evaluating the function;
Boolean.TRUE
orBoolean.FALSE
- Throws:
FunctionCallException
- ifargs
has more or less than one item
-
evaluate
public static java.lang.Boolean evaluate(java.lang.Object obj, Navigator nav)
Convert the argument
obj
to aBoolean
according to the following rules:- Lists are false if they're empty; true if they're not.
- Booleans are false if they're false; true if they're true.
- Strings are false if they're empty; true if they're not.
- Numbers are false if they're 0 or NaN; true if they're not.
- All other objects are true.
- Parameters:
obj
- the object to convert to a booleannav
- ignored- Returns:
Boolean.TRUE
orBoolean.FALSE
-
-