Project Wonder 2.0

er.extensions
Class ERXValueUtilities

java.lang.Object
  extended byer.extensions.ERXValueUtilities

public class ERXValueUtilities
extends Object

ERXValueUtilities has usefull 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.


Constructor Summary
ERXValueUtilities()
           
 
Method Summary
static NSArray arrayValue(Object obj)
          Basic utility method for reading NSArray values which works also with Strings.
static NSArray arrayValueWithDefault(Object obj, NSArray def)
          Basic utility method for reading NSArray values which also works with serialzed NSArrays.
static BigDecimal bigDecimalValue(Object obj)
          Basic utility method for reading BigDecimal values which works also with Strings.
static BigDecimal bigDecimalValueWithDefault(Object obj, BigDecimal def)
          Basic utility method for reading BigDecimal values.
static boolean booleanValue(Object obj)
          Basic utility method for determining if an object represents either a true or false value.
static boolean booleanValueForBindingOnComponentWithDefault(String binding, WOComponent component, boolean def)
          This method resolves bindings from WOComponents to boolean values.
static boolean booleanValueWithDefault(Object obj, boolean def)
          Basic utility method for determining if an object represents either a true or false value.
static NSDictionary dictionaryValue(Object obj)
          Basic utility method for reading NSDictionary values which works also with Strings.
static NSDictionary dictionaryValueWithDefault(Object obj, NSDictionary def)
          Basic utility method for reading NSDictionary values which also works with serialzed NSDictionarys.
static int intValue(Object obj)
          Basic utility method for reading int values.
static int intValueForBindingOnComponentWithDefault(String binding, WOComponent component, int def)
          This method resolves bindings from WOComponents to int values.
static int intValueWithDefault(Object obj, int def)
          Basic utility method for reading int values.
static long longValue(Object obj)
          Basic utility method for reading long values.
static long longValueForBindingOnComponentWithDefault(String binding, WOComponent component, long def)
          This method resolves bindings from WOComponents to long values.
static long longValueWithDefault(Object obj, long def)
          Basic utility method for reading long values.
 
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

booleanValueForBindingOnComponentWithDefault

public static boolean booleanValueForBindingOnComponentWithDefault(String binding,
                                                                   WOComponent component,
                                                                   boolean def)
This method resolves bindings from WOComponents to boolean values. The added benefit (and this might not still be the case) is that when false is bound to a binding will pass through null. This makes it difficult to handle the case where a binding should default to true but false was actually bound to the binding.
Note: This is only needed for non-syncronizing components

Parameters:
binding - name of the binding
component - to resolve binding request
def - default value if binding is not set
Returns:
boolean resolution of the object returned from the valueForBinding request.

booleanValue

public static boolean booleanValue(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(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, a Number or a ERXUtilities.BooleanOperation. Numbers are false if they equal 0, Strings are false if they equal (case insensitive) 'no', 'false' or parse to 0. ERXUtilities.BooleanOperation are false if value returns false. 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

intValueForBindingOnComponentWithDefault

public static int intValueForBindingOnComponentWithDefault(String binding,
                                                           WOComponent component,
                                                           int def)
This method resolves bindings from WOComponents to int values. Note: This is only needed for non-syncronizing components

Parameters:
binding - name of the binding
component - to resolve binding request
def - default value if binding is not set
Returns:
boolean resolution of the object returned from the valueForBinding request.

intValue

public static int intValue(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:
boolean evaluation of the given object

intValueWithDefault

public static int intValueWithDefault(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:
int evaluation of the given object

longValueForBindingOnComponentWithDefault

public static long longValueForBindingOnComponentWithDefault(String binding,
                                                             WOComponent component,
                                                             long def)
This method resolves bindings from WOComponents to long values. Note: This is only needed for non-syncronizing components

Parameters:
binding - name of the binding
component - to resolve binding request
def - default value if binding is not set
Returns:
boolean resolution of the object returned from the valueForBinding request.

longValue

public static long longValue(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:
boolean evaluation of the given object

longValueWithDefault

public static long longValueWithDefault(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

arrayValue

public static NSArray arrayValue(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 NSArray arrayValueWithDefault(Object obj,
                                            NSArray def)
Basic utility method for reading NSArray values which also works with serialzed NSArrays. The default value is used if the object is null.

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

dictionaryValue

public static NSDictionary dictionaryValue(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 NSDictionary dictionaryValueWithDefault(Object obj,
                                                      NSDictionary def)
Basic utility method for reading NSDictionary values which also works with serialzed 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:
int evaluation of the given object

bigDecimalValue

public static BigDecimal bigDecimalValue(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 BigDecimal bigDecimalValueWithDefault(Object obj,
                                                    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:
int evaluation of the given object

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.