Project Wonder 5.0

er.extensions.foundation
Class ERXValueUtilities

java.lang.Object
  extended by er.extensions.foundation.ERXValueUtilities

public class ERXValueUtilities
extends java.lang.Object

ERXValueUtilities has useful conversion methods for reading and transforming boolean, int and floatvalues. Unless otherwise stated, when an empty string (or one containing only whitespace) is given, then the string is assumed to be null. This is because D2W is not able to give back null values anymore.

Author:
ak on Mon Oct 28 2002

Constructor Summary
ERXValueUtilities()
           
 
Method Summary
static com.webobjects.foundation.NSArray arrayValue(java.lang.Object obj)
          Basic utility method for reading NSArray values which works also with Strings.
static com.webobjects.foundation.NSArray arrayValueWithDefault(java.lang.Object obj, com.webobjects.foundation.NSArray def)
          Basic utility method for reading NSArray values which also works with serialized NSArrays and comma separated items.
static java.math.BigDecimal bigDecimalValue(java.lang.Object obj)
          Basic utility method for reading BigDecimal values which works also with Strings.
static java.math.BigDecimal bigDecimalValueWithDefault(java.lang.Object obj, java.math.BigDecimal def)
          Basic utility method for reading BigDecimal values.
static boolean booleanValue(java.lang.Object obj)
          Basic utility method for determining if an object represents either a true or false value.
static boolean booleanValueForBindingOnComponentWithDefault(java.lang.String binding, com.webobjects.appserver.WOComponent component, boolean def)
          Deprecated. use ERXComponentUtilities.booleanValueForBinding(component, binding, def)
static boolean booleanValueWithDefault(java.lang.Object obj, boolean def)
          Basic utility method for determining if an object represents either a true or false value.
static java.lang.Boolean BooleanValueWithDefault(java.lang.Object obj, java.lang.Boolean def)
          Basic utility method for determining if an object represents either a true or false value.
static int compare(int int1, int int2)
          Returns the comparison value between int1 and int2 (using Comparator rules)
static com.webobjects.foundation.NSData dataValue(java.lang.Object obj)
          Basic utility method for reading NSData values which works also with Strings.
static com.webobjects.foundation.NSData dataValueWithDefault(java.lang.Object obj, com.webobjects.foundation.NSData def)
          Basic utility method for reading NSData values which also works with serialized NSData.
static com.webobjects.foundation.NSDictionary dictionaryValue(java.lang.Object obj)
          Basic utility method for reading NSDictionary values which works also with Strings.
static com.webobjects.foundation.NSDictionary dictionaryValueWithDefault(java.lang.Object obj, com.webobjects.foundation.NSDictionary def)
          Basic utility method for reading NSDictionary values which also works with serialized NSDictionarys.
static double doubleValue(java.lang.Object obj)
          Basic utility method for reading double values.
static double doubleValueWithDefault(java.lang.Object obj, double def)
          Basic utility method for reading double values.
static java.lang.Double DoubleValueWithDefault(java.lang.Object obj, java.lang.Double def)
          Basic utility method for reading Double values.
static
<T extends java.lang.Enum<T>>
T
enumValue(java.lang.Object obj, java.lang.Class<T> enumType)
          Basic utility method for reading Enum values.
static
<T extends java.lang.Enum<T>>
T
enumValueWithDefault(java.lang.Object obj, java.lang.Class<T> enumType, T def)
          Basic utility method for reading Enum values.
static
<T extends java.lang.Enum<T>>
T
enumValueWithRequiredDefault(java.lang.Object obj, T def)
          Basic utility method for reading Enum values.
static float floatValue(java.lang.Object obj)
          Basic utility method for reading float values.
static float floatValueWithDefault(java.lang.Object obj, float def)
          Basic utility method for reading float values.
static java.lang.Float FloatValueWithDefault(java.lang.Object obj, java.lang.Float def)
          Basic utility method for reading Float values.
static java.lang.Integer IntegerValueWithDefault(java.lang.Object obj, java.lang.Integer def)
          Basic utility method for reading Integer values.
static int intValue(java.lang.Object obj)
          Basic utility method for reading int values.
static int intValueWithDefault(java.lang.Object obj, int def)
          Basic utility method for reading int values.
static boolean isNull(java.lang.Object obj)
          Returns whether or not the given object is null or NSKVC.Null.
static long longValue(java.lang.Object obj)
          Basic utility method for reading long values.
static long longValueWithDefault(java.lang.Object obj, long def)
          Basic utility method for reading long values.
static java.lang.Long LongValueWithDefault(java.lang.Object obj, java.lang.Long def)
          Basic utility method for reading Long values.
static com.webobjects.foundation.NSSet setValue(java.lang.Object obj)
          Basic utility method for reading NSSet values which works also with Strings.
static com.webobjects.foundation.NSSet setValueWithDefault(java.lang.Object obj, com.webobjects.foundation.NSSet def)
          Basic utility method for reading NSSet values which also works with serialized NSSets and comma separated items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXValueUtilities

public ERXValueUtilities()
Method Detail

isNull

public static boolean isNull(java.lang.Object obj)
Returns whether or not the given object is null or NSKVC.Null.

Parameters:
obj - the object to check
Returns:
true if the object is null or NSKVC.Null

booleanValueForBindingOnComponentWithDefault

public static boolean booleanValueForBindingOnComponentWithDefault(java.lang.String binding,
                                                                   com.webobjects.appserver.WOComponent component,
                                                                   boolean def)
Deprecated. use ERXComponentUtilities.booleanValueForBinding(component, binding, def)

Parameters:
binding - the binding to parse
component - the component to evaluate the binding on
def - the default value if the binding value is null
Returns:
the boolean value of the binding

booleanValue

public static boolean booleanValue(java.lang.Object obj)
Basic utility method for determining if an object represents either a true or false value. The current implementation tests if the object is an instance of a String or a Number. Numbers are false if they equal 0, Strings are false if they equal (case insensitive) 'no', 'false' or parse to 0.

Parameters:
obj - object to be evaluated
Returns:
boolean evaluation of the given object

booleanValueWithDefault

public static boolean booleanValueWithDefault(java.lang.Object obj,
                                              boolean def)
Basic utility method for determining if an object represents either a true or false value. The current implementation tests if the object is an instance of a String, or a Number. Numbers are false if they equal 0, Strings are false if they equal (case insensitive) 'no', 'false' or parse to 0. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
boolean evaluation of the given object

BooleanValueWithDefault

public static java.lang.Boolean BooleanValueWithDefault(java.lang.Object obj,
                                                        java.lang.Boolean def)
Basic utility method for determining if an object represents either a true or false value. The current implementation tests if the object is an instance of a String, or a Number. Numbers are false if they equal 0, Strings are false if they equal (case insensitive) 'no', 'false' or parse to 0. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
boolean evaluation of the given object

intValue

public static int intValue(java.lang.Object obj)
Basic utility method for reading int values. The current implementation uses intValueWithDefault(Object, int) with a default of 0.

Parameters:
obj - object to be evaluated
Returns:
integer evaluation of the given object

intValueWithDefault

public static int intValueWithDefault(java.lang.Object obj,
                                      int def)
Basic utility method for reading int values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
integer evaluation of the given object

IntegerValueWithDefault

public static java.lang.Integer IntegerValueWithDefault(java.lang.Object obj,
                                                        java.lang.Integer def)
Basic utility method for reading Integer values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
Integer evaluation of the given object

floatValue

public static float floatValue(java.lang.Object obj)
Basic utility method for reading float values. The current implementation uses floatValueWithDefault(Object, float) with a default of 0.

Parameters:
obj - object to be evaluated
Returns:
float evaluation of the given object

floatValueWithDefault

public static float floatValueWithDefault(java.lang.Object obj,
                                          float def)
Basic utility method for reading float values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
float evaluation of the given object

FloatValueWithDefault

public static java.lang.Float FloatValueWithDefault(java.lang.Object obj,
                                                    java.lang.Float def)
Basic utility method for reading Float values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
Float evaluation of the given object

doubleValue

public static double doubleValue(java.lang.Object obj)
Basic utility method for reading double values. The current implementation uses doubleValueWithDefault(Object, double) with a default of 0.

Parameters:
obj - object to be evaluated
Returns:
double evaluation of the given object

doubleValueWithDefault

public static double doubleValueWithDefault(java.lang.Object obj,
                                            double def)
Basic utility method for reading double values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
double evaluation of the given object

DoubleValueWithDefault

public static java.lang.Double DoubleValueWithDefault(java.lang.Object obj,
                                                      java.lang.Double def)
Basic utility method for reading Double values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
Double evaluation of the given object

longValue

public static long longValue(java.lang.Object obj)
Basic utility method for reading long values. The current implementation uses longValueWithDefault(Object, long) with a default of 0.

Parameters:
obj - object to be evaluated
Returns:
long evaluation of the given object

longValueWithDefault

public static long longValueWithDefault(java.lang.Object obj,
                                        long def)
Basic utility method for reading long values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
long evaluation of the given object

LongValueWithDefault

public static java.lang.Long LongValueWithDefault(java.lang.Object obj,
                                                  java.lang.Long def)
Basic utility method for reading Long values. The current implementation tests if the object is an instance of a String, Number and Boolean. Booleans are 1 if they equal true. The default value is used if the object is null or the boolean value is false.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
Long evaluation of the given object

arrayValue

public static com.webobjects.foundation.NSArray arrayValue(java.lang.Object obj)
Basic utility method for reading NSArray values which works also with Strings. The current implementation uses arrayValueWithDefault(Object, NSArray) with a default of null.

Parameters:
obj - object to be evaluated
Returns:
NSArray evaluation of the given object

arrayValueWithDefault

public static com.webobjects.foundation.NSArray arrayValueWithDefault(java.lang.Object obj,
                                                                      com.webobjects.foundation.NSArray def)
Basic utility method for reading NSArray values which also works with serialized NSArrays and comma separated items. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
NSArray evaluation of the given object

setValue

public static com.webobjects.foundation.NSSet setValue(java.lang.Object obj)
Basic utility method for reading NSSet values which works also with Strings. The current implementation uses setValueWithDefault(Object, NSSet) with a default of null.

Parameters:
obj - object to be evaluated
Returns:
NSSet evaluation of the given object

setValueWithDefault

public static com.webobjects.foundation.NSSet setValueWithDefault(java.lang.Object obj,
                                                                  com.webobjects.foundation.NSSet def)
Basic utility method for reading NSSet values which also works with serialized NSSets and comma separated items. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
NSSet evaluation of the given object

dictionaryValue

public static com.webobjects.foundation.NSDictionary dictionaryValue(java.lang.Object obj)
Basic utility method for reading NSDictionary values which works also with Strings. The current implementation uses dictionaryValueWithDefault(Object, NSDictionary) with a default of null.

Parameters:
obj - object to be evaluated
Returns:
NSDictionary evaluation of the given object

dictionaryValueWithDefault

public static com.webobjects.foundation.NSDictionary dictionaryValueWithDefault(java.lang.Object obj,
                                                                                com.webobjects.foundation.NSDictionary def)
Basic utility method for reading NSDictionary values which also works with serialized NSDictionarys. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
NSDictionary evaluation of the given object

dataValue

public static com.webobjects.foundation.NSData dataValue(java.lang.Object obj)
Basic utility method for reading NSData values which works also with Strings. The current implementation uses dataValueWithDefault(Object, NSData) with a default of null.

Parameters:
obj - object to be evaluated
Returns:
NSData evaluation of the given object

dataValueWithDefault

public static com.webobjects.foundation.NSData dataValueWithDefault(java.lang.Object obj,
                                                                    com.webobjects.foundation.NSData def)
Basic utility method for reading NSData values which also works with serialized NSData. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
NSData evaluation of the given object

bigDecimalValue

public static java.math.BigDecimal bigDecimalValue(java.lang.Object obj)
Basic utility method for reading BigDecimal values which works also with Strings. The current implementation uses bigDecimalValueWithDefault(Object, BigDecimal) with a default of null.

Parameters:
obj - object to be evaluated
Returns:
BigDecimal evaluation of the given object

bigDecimalValueWithDefault

public static java.math.BigDecimal bigDecimalValueWithDefault(java.lang.Object obj,
                                                              java.math.BigDecimal def)
Basic utility method for reading BigDecimal values. The default value is used if the object is null.

Parameters:
obj - object to be evaluated
def - default value if object is null
Returns:
BigDecimal evaluation of the given object

compare

public static int compare(int int1,
                          int int2)
Returns the comparison value between int1 and int2 (using Comparator rules)

Parameters:
int1 - value 1
int2 - value 2
Returns:
the Comparator comparison between the two values

enumValue

public static <T extends java.lang.Enum<T>> T enumValue(java.lang.Object obj,
                                                        java.lang.Class<T> enumType)
Basic utility method for reading Enum values.

Type Parameters:
T - Enum type evaluated
Parameters:
obj - object to evaluate
enumType - The desired enum class
Returns:
Enum evaluation of the given object or the default

enumValueWithRequiredDefault

public static <T extends java.lang.Enum<T>> T enumValueWithRequiredDefault(java.lang.Object obj,
                                                                           T def)
Basic utility method for reading Enum values.

Type Parameters:
T - enum type evaluated
Parameters:
obj - object to be evaluated
def - default value returned if object is null. If this value is null, the method throws a NullPointerException
Returns:
Enum evaluation of the given object

enumValueWithDefault

public static <T extends java.lang.Enum<T>> T enumValueWithDefault(java.lang.Object obj,
                                                                   java.lang.Class<T> enumType,
                                                                   T def)
Basic utility method for reading Enum values.

Type Parameters:
T - Enum type evaluated
Parameters:
obj - object to evaluate
enumType - The desired enum class
def - default value returned if obj is null.
Returns:
Enum evaluation of the given object or the default

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.