SilverStream
Application Server 3.5

com.sssw.rt.util
Class AgConvert

java.lang.Object
 |
 +--com.sssw.rt.util.AgConvert

public class AgConvert
extends Object

This class provides static conversion routines between various java types.


Method Summary
static boolean equals(Object v1, Object v2)
          Compare two values by converting one to the type of the other.
static boolean equals(Object v1, Object v2, Locale locale)
          Compare two values by converting one to the type of the other.
static boolean equals(Object v1, Object v2, Locale locale, String zoneStr)
          Compare two values by converting one to the type of the other.
static BigDecimal toBigDecimal(Object v)
          Convert the object to a BigDecimal using the default locale
static BigDecimal toBigDecimal(Object v, Locale locale)
          Convert the object to a BigDecimal using the specified locale
static Blob toBlob(Object v)
          Convert the object to a Blob using the default locale.
static Blob toBlob(Object v, Locale locale)
          Convert the object to a Blob using the specified locale.
static Boolean toBoolean(Object v)
          Convert the object to a Boolean using the default locale
static Boolean toBoolean(Object v, Locale locale)
          Convert the object to a Boolean using the specified locale.
static Byte toByte(Object v)
          Convert the object to a Byte using the default locale.
static Byte toByte(Object v, Locale locale)
          Convert the object to a Byte using the specified locale.
static byte[] toByteArray(Object v)
          Convert the object to a byte array using the default locale.
static byte[] toByteArray(Object v, Locale locale)
          Convert the object to a byte array using the specified locale.
static Character toChar(Object v)
          Convert the object to a Character using the default locale.
static Character toChar(Object v, Locale locale)
          Convert the object to a Character using the specified locale.
static Object toClassInstance(Object o, Class c)
          Returns Object of desired class.
static Object toClassInstance(Object o, Class c, Locale locale)
          Returns Object of desired class using the specified locale.
static Object toClassInstance(Object o, Class c, Locale locale, String zoneStr)
          Returns Object of desired class using the specified locale and timezone.
static Clob toClob(Object v)
          Convert the object to a Clob using the default locale.
static Clob toClob(Object v, Locale locale)
          Convert the object to a Clob using the specified locale.
static Double toDouble(Object v)
          Convert the object to a Double using the default locale
static Double toDouble(Object v, Locale locale)
          Convert the object to a Double using the specified locale
static Float toFloat(Object v)
          Convert the object to a Float using the default locale
static Float toFloat(Object v, Locale locale)
          Convert the object to a Double using the specified locale
static Integer toInteger(Object v)
          Convert the object to a Integer using the default locale
static Integer toInteger(Object v, Locale locale)
          Convert the object to a Integer using the specified locale
static Long toLong(Object v)
          Convert the object to a Integer using the default locale
static Long toLong(Object v, Locale locale)
          Convert the object to a Integer using the specified locale
static boolean toPrimitiveBoolean(Object v)
          Converts the object to a primitive boolean.
static byte toPrimitiveByte(Object v)
          Converts the object to a primitive byte.
static char toPrimitiveCharacter(Object v)
          Converts the object to a primitive char.
static double toPrimitiveDouble(Object v)
          Converts the object to a primitive double.
static float toPrimitiveFloat(Object v)
          Converts the object to a primitive float.
static int toPrimitiveInteger(Object v)
          Converts the object to a primitive integer.
static long toPrimitiveLong(Object v)
          Converts the object to a primitive long.
static Short toShort(Object v)
          Convert the object to a Short using the default locale.
static Short toShort(Object v, Locale locale)
          Convert the object to a Short using the specified locale.
static Date toSqlDate(Object v)
          Convert the object to a java.sql.Date using the default locale.
static Date toSqlDate(Object v, Locale locale)
          Convert the object to a java.sql.Date using the specified locale.
static Date toSqlDate(Object v, Locale locale, String zoneStr)
          Convert the object to a java.sql.Date using the specified locale and timezone.
static String toString(Object v)
          Convert the object to a String using the default locale
static String toString(Object v, Locale locale)
          Convert the object to a String using the specified locale
static String toString(Object v, Locale locale, String zoneStr)
          Convert the object to a String using the specified locale and timezone
static Time toTime(Object v)
          Convert the object to a java.sql.Time using the default locale.
static Time toTime(Object v, Locale locale)
          Convert the object to a java.sql.Time using the specified locale.
static Time toTime(Object v, Locale locale, String zoneStr)
          Convert the object to a java.sql.Time using the specified locale and timezone.
static Timestamp toTimestamp(Object v)
          Convert the object to a java.sql.Timestamp using the default locale.
static Timestamp toTimestamp(Object v, Locale locale)
          Convert the object to a java.sql.Timestamp using the specified locale.
static Timestamp toTimestamp(Object v, Locale locale, String zoneStr)
          Convert the object to a java.sql.Timestamp using the specified locale and timezone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toString

public static String toString(Object v)
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 v,
                              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 v,
                              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 v)
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 v,
                                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 v)
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 v,
                            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 v)
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 v,
                          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

toChar

public static Character toChar(Object v)
Convert the object to a Character using the default locale. Values are constrained to Character.MIN_VALUE and Character.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

toChar

public static Character toChar(Object v,
                               Locale locale)
Convert the object to a Character using the specified locale. Values are constrained to Character.MIN_VALUE and Character.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 v)
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 v,
                          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 v)
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 v,
                              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 v)
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 v,
                            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 v)
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 v,
                                      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 v)
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 v,
                                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

toBlob

public static Blob toBlob(Object v)
Convert the object to a Blob using the default locale.
Returns:
null if the object is null or cannot be converted

toBlob

public static Blob toBlob(Object v,
                          Locale locale)
Convert the object to a Blob using the specified locale.
Returns:
null if the object is null or cannot be converted

toClob

public static Clob toClob(Object v)
Convert the object to a Clob using the default locale.
Returns:
null if the object is null or cannot be converted

toClob

public static Clob toClob(Object v,
                          Locale locale)
Convert the object to a Clob using the specified locale.
Returns:
null if the object is null or cannot be converted

toSqlDate

public static Date toSqlDate(Object v)
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 v,
                             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 v,
                             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 v)
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 v,
                          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 v,
                          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 v)
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 v,
                                    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 v,
                                    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 v)
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 v,
                                 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

toClassInstance

public static Object toClassInstance(Object o,
                                     Class c)
Returns Object of desired class.
Returns:
null if the object is null or cannot be converted

toClassInstance

public static Object toClassInstance(Object o,
                                     Class c,
                                     Locale locale)
Returns Object of desired class using the specified locale.
Returns:
null if the object is null or cannot be converted

toClassInstance

public static Object toClassInstance(Object o,
                                     Class c,
                                     Locale locale,
                                     String zoneStr)
Returns Object of desired class using the specified locale and timezone.
Returns:
null if the object is null or cannot be converted

toPrimitiveInteger

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

toPrimitiveBoolean

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

toPrimitiveDouble

public static double toPrimitiveDouble(Object v)
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 v)
Converts the object to a primitive long.
Returns:
0 if the object is null or cannot be converted

toPrimitiveFloat

public static float toPrimitiveFloat(Object v)
Converts the object to a primitive float.
Returns:
0 if the object is null or cannot be converted

toPrimitiveByte

public static byte toPrimitiveByte(Object v)
Converts the object to a primitive byte.
Returns:
0 if the object is null or cannot be converted

toPrimitiveCharacter

public static char toPrimitiveCharacter(Object v)
Converts the object to a primitive char.
Returns:
0 if the object is null or cannot be converted

equals

public static boolean equals(Object v1,
                             Object v2)
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 v1,
                             Object v2,
                             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 v1,
                             Object v2,
                             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.

SilverStream
Application Server 3.5