Class BooleanFunction

java.lang.Object
org.jaxen.function.BooleanFunction
All Implemented Interfaces:
Function

public class BooleanFunction extends 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

See Also:
  • Constructor Details

    • BooleanFunction

      public BooleanFunction()
      Create a new BooleanFunction object.
  • Method Details

    • call

      public Object call(Context context, List args) throws FunctionCallException
      Convert the argument to a Boolean
      Specified by:
      call in interface Function
      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 Boolean
      Returns:
      the result of evaluating the function; Boolean.TRUE or Boolean.FALSE
      Throws:
      FunctionCallException - if args has more or less than one item
    • evaluate

      public static Boolean evaluate(Object obj, Navigator nav)

      Convert the argument obj to a Boolean 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 boolean
      nav - ignored
      Returns:
      Boolean.TRUE or Boolean.FALSE