Diamond Control Suite 3.0

diamondedge.util
Class Obj

java.lang.Object
  extended by diamondedge.util.Obj

public class Obj
extends Object


Constructor Summary
Obj()
           
 
Method Summary
static int compare(Object o1, Object o2)
          Compares two Objects numerically or lexicographically depending on the datatypes.
static int compare(Object o1, Object o2, boolean caseSensitive)
          Compares two Objects numerically or lexicographically depending on the datatypes.
static Number parseNumber(String str)
          Return a Number instance by trying to parse the string in the following formats: Integer, number, percent, currency.
static Object parseObject(Object val)
          Attempts to parse the value into a Number, Boolean, Date in that order and returns the object.
static boolean toBoolean(Object val)
           
static Date toDate(Object val)
           
static Date toDateNew(Object val)
           
static BigDecimal toDecimal(Object val)
           
static double toDouble(Object val)
           
static int toInt(Object val)
           
static long toLong(Object val)
           
static Number toNumber(Object val)
           
static String toString(Object val)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Obj

public Obj()
Method Detail

compare

public static int compare(Object o1,
                          Object o2)
Compares two Objects numerically or lexicographically depending on the datatypes. Strings are compared case insensitive.

See Also:
compare(Object,Object,boolean)

compare

public static int compare(Object o1,
                          Object o2,
                          boolean caseSensitive)
Compares two Objects numerically or lexicographically depending on the datatypes. If either object is a Date then their getTime() are compared. If either object is a Number then their double values are compared. If either are strings then they are compared lexicographically. If only one object is the type mentioned above then the other object is converted to the same type.
  return 0 if the objects are equal
  return a value > 0 if o1 is > than o2
  return a value < 0 if o1 is < than o2

Parameters:
caseSensitive - - if one of the objects is a String then use a case sensitive comparison

toNumber

public static Number toNumber(Object val)

toInt

public static int toInt(Object val)

toLong

public static long toLong(Object val)

toDouble

public static double toDouble(Object val)

toDecimal

public static BigDecimal toDecimal(Object val)

toBoolean

public static boolean toBoolean(Object val)

toDate

public static Date toDate(Object val)

toDateNew

public static Date toDateNew(Object val)

toString

public static String toString(Object val)

parseNumber

public static final Number parseNumber(String str)
                                throws ParseException
Return a Number instance by trying to parse the string in the following formats: Integer, number, percent, currency. Throws an exception if the entire string cannot be converted to a number. Returns null for empty or null strings.

Throws:
ParseException

parseObject

public static final Object parseObject(Object val)
Attempts to parse the value into a Number, Boolean, Date in that order and returns the object. If it cannot be converted then the original value is returned. Strings formatted according to the current locale for currencies and percents will be converted to Doubles.

See Also:
parseNumber(java.lang.String)

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.