Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboConvert

java.lang.Object
 |
 +--com.sssw.fw.util.EboConvert

public class EboConvert
extends Object

This class provides static conversion routines between various Java types.


Constructor Summary
EboConvert()
           
 
Method Summary
static boolean equals(Object obj1, Object obj2)
          Compare two values by converting one to the type of the other.
static boolean equals(Object obj1, Object obj2, Locale locale)
          Compare two values by converting one to the type of the other.
static boolean equals(Object obj1, Object obj2, Locale locale, String zoneStr)
          Compare two values by converting one to the type of the other.
static BigDecimal toBigDecimal(Object obj)
          Convert the object to a BigDecimal using the default locale
static BigDecimal toBigDecimal(Object obj, Locale locale)
          Convert the object to a BigDecimal using the specified locale
static Boolean toBoolean(Object obj)
          Convert the object to a Boolean using the default locale
static Boolean toBoolean(Object obj, Locale locale)
          Convert the object to a Boolean using the specified locale.
static Byte toByte(Object obj)
          Convert the object to a Byte using the default locale.
static Byte toByte(Object obj, Locale locale)
          Convert the object to a Byte using the specified locale.
static byte[] toByteArray(Object obj)
          Convert the object to a byte array using the default locale.
static byte[] toByteArray(Object obj, Locale locale)
          Convert the object to a byte array using the specified locale.
static Object toClassInstance(Object obj, Class c)
          returns Object of desired class, or null if conversion is not possible
static Object toClassInstance(Object obj, Class c, Locale locale)
          returns Object of desired class, or null if conversion is not possible
static Object toClassInstance(Object obj, Class c, Locale locale, String zoneStr)
          returns Object of desired class, or null if conversion is not possible
static Double toDouble(Object obj)
          Convert the object to a Double using the default locale
static Double toDouble(Object obj, Locale locale)
          Convert the object to a Double using the specified locale
static Float toFloat(Object obj)
          Convert the object to a Float using the default locale
static Float toFloat(Object obj, Locale locale)
          Convert the object to a Double using the specified locale
static int toInt(Object obj)
          Converts the object to a primitive integer.
static Integer toInteger(Object obj)
          Convert the object to a Integer using the default locale
static Integer toInteger(Object obj, Locale locale)
          Convert the object to a Integer using the specified locale
static Integer[] toIntegerArray(int[] arr)
          Convert an array of primitive int's into an array of Integer objects.
static Long toLong(Object obj)
          Convert the object to a Integer using the default locale
static Long toLong(Object obj, Locale locale)
          Convert the object to a Integer using the specified locale
static boolean toPrimitiveBoolean(Object obj)
          Converts the object to a primitive boolean.
static double toPrimitiveDouble(Object obj)
          Converts the object to a primitive double.
static int toPrimitiveInteger(Object obj)
          Converts the object to a primitive integer.
static long toPrimitiveLong(Object obj)
          Converts the object to a primitive long.
static Short toShort(Object obj)
          Convert the object to a Short using the default locale.
static Short toShort(Object obj, Locale locale)
          Convert the object to a Short using the specified locale.
static Date toSqlDate(Object obj)
          Convert the object to a java.sql.Date using the default locale.
static Date toSqlDate(Object obj, Locale locale)
          Convert the object to a java.sql.Date using the specified locale.
static Date toSqlDate(Object obj, Locale locale, String zoneStr)
          Convert the object to a java.sql.Date using the specified locale and timezone.
static String toString(Object obj)
          Convert the object to a String using the default locale
static String toString(Object obj, Locale locale)
          Convert the object to a String using the specified locale
static String toString(Object obj, Locale locale, String zoneStr)
          Convert the object to a String using the specified locale and timezone
static String[] toStringArray(Vector v)
          Convert a Vector of Objects to a String Array by calling o.toString() on each
static Time toTime(Object obj)
          Convert the object to a java.sql.Time using the default locale.
static Time toTime(Object obj, Locale locale)
          Convert the object to a java.sql.Time using the specified locale.
static Time toTime(Object obj, Locale locale, String zoneStr)
          Convert the object to a java.sql.Time using the specified locale and timezone.
static Timestamp toTimestamp(Object obj)
          Convert the object to a java.sql.Timestamp using the default locale.
static Timestamp toTimestamp(Object obj, Locale locale)
          Convert the object to a java.sql.Timestamp using the specified locale.
static Timestamp toTimestamp(Object obj, Locale locale, String zoneStr)
          Convert the object to a java.sql.Timestamp using the specified locale and timezone.
static Object toType(Object obj, char datatypecode)
          Converts an object to specified datatype
static Object toType(Object obj, char datatypecode, Locale locale)
          Converts an object to specified datatype for locale specified
static Object toType(Object obj, char datatypecode, Locale locale, String zoneStr)
          Converts an object to specified datatype for locale specified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EboConvert

public EboConvert()
Method Detail

toString

public static String toString(Object obj)
Convert the object to a String using the default locale
Returns:
null if the object is null or cannot be converted

toString

public static String toString(Object obj,
                              Locale locale)
Convert the object to a String using the specified locale
Returns:
null if the object is null or cannot be converted

toString

public static String toString(Object obj,
                              Locale locale,
                              String zoneStr)
Convert the object to a String using the specified locale and timezone
Returns:
null if the object is null or cannot be converted

toInteger

public static Integer toInteger(Object obj)
Convert the object to a Integer using the default locale
Returns:
null if the object is null or cannot be converted

toInteger

public static Integer toInteger(Object obj,
                                Locale locale)
Convert the object to a Integer using the specified locale
Returns:
null if the object is null or cannot be converted

toShort

public static Short toShort(Object obj)
Convert the object to a Short using the default locale. Integer values larger than the size of a short are masked. That is, only the portion less than short-max is returned.
Returns:
null if the object is null or cannot be converted

toShort

public static Short toShort(Object obj,
                            Locale locale)
Convert the object to a Short using the specified locale. Integer values larger than the size of a short are masked. That is, only the portion less than short-max is returned.
Returns:
null if the object is null or cannot be converted

toByte

public static Byte toByte(Object obj)
Convert the object to a Byte using the default locale. Values are constrained to Byte.MIN_VALUE and Byte.MAX_VALUE. That is, if the value falls outside that range, one of those values is returned.
Returns:
null if the object is null or cannot be converted

toByte

public static Byte toByte(Object obj,
                          Locale locale)
Convert the object to a Byte using the specified locale. Values are constrained to Byte.MIN_VALUE and Byte.MAX_VALUE. That is, if the value falls outside that range, one of those values is returned.
Returns:
null if the object is null or cannot be converted

toLong

public static Long toLong(Object obj)
Convert the object to a Integer using the default locale
Returns:
null if the object is null or cannot be converted

toLong

public static Long toLong(Object obj,
                          Locale locale)
Convert the object to a Integer using the specified locale
Returns:
null if the object is null or cannot be converted

toDouble

public static Double toDouble(Object obj)
Convert the object to a Double using the default locale
Returns:
null if the object is null or cannot be converted

toDouble

public static Double toDouble(Object obj,
                              Locale locale)
Convert the object to a Double using the specified locale
Returns:
null if the object is null or cannot be converted

toFloat

public static Float toFloat(Object obj)
Convert the object to a Float using the default locale
Returns:
null if the object is null or cannot be converted

toFloat

public static Float toFloat(Object obj,
                            Locale locale)
Convert the object to a Double using the specified locale
Returns:
null if the object is null or cannot be converted

toBigDecimal

public static BigDecimal toBigDecimal(Object obj)
Convert the object to a BigDecimal using the default locale
Returns:
null if the object is null or cannot be converted

toBigDecimal

public static BigDecimal toBigDecimal(Object obj,
                                      Locale locale)
Convert the object to a BigDecimal using the specified locale
Returns:
null if the object is null or cannot be converted

toBoolean

public static Boolean toBoolean(Object obj)
Convert the object to a Boolean using the default locale
Returns:
null if the object is null or cannot be converted

toBoolean

public static Boolean toBoolean(Object obj,
                                Locale locale)
Convert the object to a Boolean using the specified locale. Strings are TRUE unless they equal "false" or "0". Numbers are TRUE unless they equal zero.
Returns:
null if the object is null or cannot be converted

toSqlDate

public static Date toSqlDate(Object obj)
Convert the object to a java.sql.Date using the default locale.
Returns:
null if the object is null or cannot be converted

toSqlDate

public static Date toSqlDate(Object obj,
                             Locale locale)
Convert the object to a java.sql.Date using the specified locale.
Returns:
null if the object is null or cannot be converted

toSqlDate

public static Date toSqlDate(Object obj,
                             Locale locale,
                             String zoneStr)
Convert the object to a java.sql.Date using the specified locale and timezone.
Returns:
null if the object is null or cannont be converted

toTime

public static Time toTime(Object obj)
Convert the object to a java.sql.Time using the default locale.
Returns:
null if the object is null or cannot be converted

toTime

public static Time toTime(Object obj,
                          Locale locale)
Convert the object to a java.sql.Time using the specified locale.
Returns:
null if the object is null or cannot be converted

toTime

public static Time toTime(Object obj,
                          Locale locale,
                          String zoneStr)
Convert the object to a java.sql.Time using the specified locale and timezone.
Returns:
null if the object is null or cannot be converted

toTimestamp

public static Timestamp toTimestamp(Object obj)
Convert the object to a java.sql.Timestamp using the default locale.
Returns:
null if the object is null or cannot be converted

toTimestamp

public static Timestamp toTimestamp(Object obj,
                                    Locale locale)
Convert the object to a java.sql.Timestamp using the specified locale.
Returns:
null if the object is null or cannot be converted

toTimestamp

public static Timestamp toTimestamp(Object obj,
                                    Locale locale,
                                    String zoneStr)
Convert the object to a java.sql.Timestamp using the specified locale and timezone.
Returns:
null if the object is null or cannot be converted

toByteArray

public static byte[] toByteArray(Object obj)
Convert the object to a byte array using the default locale.
Returns:
null if the object is null or cannot be converted

toByteArray

public static byte[] toByteArray(Object obj,
                                 Locale locale)
Convert the object to a byte array using the specified locale. Strings are UTF8 encoded into bytes. Numbers are encoded with DataOutputStream. Other types are not supported.
Returns:
null if the object is null or cannot be converted

toStringArray

public static String[] toStringArray(Vector v)
Convert a Vector of Objects to a String Array by calling o.toString() on each

toIntegerArray

public static Integer[] toIntegerArray(int[] arr)
Convert an array of primitive int's into an array of Integer objects.

toClassInstance

public static Object toClassInstance(Object obj,
                                     Class c)
returns Object of desired class, or null if conversion is not possible

toClassInstance

public static Object toClassInstance(Object obj,
                                     Class c,
                                     Locale locale)
returns Object of desired class, or null if conversion is not possible

toClassInstance

public static Object toClassInstance(Object obj,
                                     Class c,
                                     Locale locale,
                                     String zoneStr)
returns Object of desired class, or null if conversion is not possible

toInt

public static int toInt(Object obj)
Converts the object to a primitive integer.
Returns:
0 if the object is null or cannot be converted

toPrimitiveInteger

public static int toPrimitiveInteger(Object obj)
Converts the object to a primitive integer.
Returns:
0 if the object is null or cannot be converted

toPrimitiveBoolean

public static boolean toPrimitiveBoolean(Object obj)
Converts the object to a primitive boolean.
Returns:
false if the object is null or cannot be converted

toPrimitiveDouble

public static double toPrimitiveDouble(Object obj)
Converts the object to a primitive double.
Returns:
0.0 if the object is null or cannot be converted

toPrimitiveLong

public static long toPrimitiveLong(Object obj)
Converts the object to a primitive long.
Returns:
0 if the object is null or cannot be converted

toType

public static Object toType(Object obj,
                            char datatypecode)
Converts an object to specified datatype
Parameters:
obj - Object to be converted
datatypecode - com.sssw.fw.util.EboDatatypeCodes.java character value representing the datatype to which obj should be converted.

toType

public static Object toType(Object obj,
                            char datatypecode,
                            Locale locale)
Converts an object to specified datatype for locale specified
Parameters:
obj - Object to be converted
datatypecode - com.sssw.fw.util.EboDatatypeCodes.java character value representing the datatype to which obj should be converted.
locale - Locale to use in coverting to specified datatype

toType

public static Object toType(Object obj,
                            char datatypecode,
                            Locale locale,
                            String zoneStr)
Converts an object to specified datatype for locale specified
Parameters:
obj - Object to be converted
datatypecode - com.sssw.fw.util.EboDatatypeCodes.java character value representing the datatype to which obj should be converted.
locale - Locale to use in coverting to specified datatype
zoneStr - Time zone string for date/time conversions

equals

public static boolean equals(Object obj1,
                             Object obj2)
Compare two values by converting one to the type of the other. Types are converted according to a precedence hierarchy.

equals

public static boolean equals(Object obj1,
                             Object obj2,
                             Locale locale)
Compare two values by converting one to the type of the other. Types are converted according to a precedence hierarchy. Conversions from String use the locale.

equals

public static boolean equals(Object obj1,
                             Object obj2,
                             Locale locale,
                             String zoneStr)
Compare two values by converting one to the type of the other. Types are converted according to a precedence hierarchy. Conversions from String use the locale and timezone.

Novell exteNd
Director 5.2 API