public class TypeConversionHelper extends Object
Constructor and Description |
---|
TypeConversionHelper() |
Modifier and Type | Method and Description |
---|---|
static Object |
convertTo(Object value,
Class type)
Convert the value to a instance of the given type.
|
static BigDecimal[] |
getBigDecimalArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static BigInteger[] |
getBigIntegerArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static BitSet |
getBitSetFromBooleanArray(boolean[] buf)
Convert a boolean[] into an instance of our value class.
|
static boolean[] |
getBooleanArrayFromBitSet(BitSet value)
Convert an instance of our value class into a boolean[].
|
static boolean[] |
getBooleanArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Boolean[] |
getBooleanObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static byte[] |
getByteArrayFromBigDecimalArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromBigIntegerArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromBooleanArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromBooleanObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromByteObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromCharArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromCharObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromDoubleArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromDoubleObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromFloatArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromFloatObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromIntArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromIntObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromLongArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromLongObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromShortArray(Object value)
Convert an instance of our value class into a byte[].
|
static byte[] |
getByteArrayFromShortObjectArray(Object value)
Convert an instance of our value class into a byte[].
|
static Byte[] |
getByteObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static byte[] |
getBytesFromInt(int val)
Utility to convert an int into a byte array
|
static byte[] |
getBytesFromShort(short val)
Utility to convert a short into a a byte array
|
static char[] |
getCharArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Character[] |
getCharObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static double[] |
getDoubleArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Double[] |
getDoubleObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getEnumForStoredValue(AbstractMemberMetaData mmd,
FieldRole role,
Object value,
ClassLoaderResolver clr) |
static float[] |
getFloatArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Float[] |
getFloatObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static String |
getHexFromInt(int val)
Utility to convert an int into a 8-char hex String
|
static String |
getHexFromShort(short val)
Utility to convert a short into a 4-char hex String
|
static int[] |
getIntArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static int |
getIntFromByteArray(byte[] bytes)
Utility to convert a byte array to an int.
|
static Integer[] |
getIntObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static JdbcType |
getJdbcTypeForEnum(AbstractMemberMetaData mmd,
FieldRole role,
ClassLoaderResolver clr) |
static long[] |
getLongArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Long[] |
getLongObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static short[] |
getShortArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Short[] |
getShortObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getStoredValueFromEnum(AbstractMemberMetaData mmd,
FieldRole role,
Enum myEnum)
Convenience method to return the "value" of an Enum, for a field and role.
|
static String |
getStringFromInt(int val)
Utility to convert an int into a byte-generated String
|
static String |
getStringFromShort(short val)
Utility to convert a short into a byte-generated String
|
static int |
intFromString(String str,
int dflt)
Convert a string into an integer.
|
static Timestamp |
stringToTimestamp(String s,
Calendar cal)
Converts a string in JDBC timestamp escape format to a Timestamp object.
|
static String |
timestampToString(Timestamp ts,
Calendar cal)
Formats a timestamp in JDBC timestamp escape format using the timezone
of the passed Calendar.
|
public static boolean[] getBooleanArrayFromBitSet(BitSet value)
value
- Object to be convertedpublic static BitSet getBitSetFromBooleanArray(boolean[] buf)
buf
- boolean array to be convertedpublic static boolean[] getBooleanArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBooleanArray(Object value)
value
- Object to be convertedpublic static char[] getCharArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromCharArray(Object value)
value
- Object to be convertedpublic static double[] getDoubleArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromDoubleArray(Object value)
value
- Object to be convertedpublic static float[] getFloatArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromFloatArray(Object value)
value
- Object to be convertedpublic static int[] getIntArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromIntArray(Object value)
value
- Object to be convertedpublic static long[] getLongArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromLongArray(Object value)
value
- Object to be convertedpublic static short[] getShortArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromShortArray(Object value)
value
- Object to be convertedpublic static byte[] getByteArrayFromBigDecimalArray(Object value)
value
- Object to be convertedpublic static BigDecimal[] getBigDecimalArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBigIntegerArray(Object value)
value
- Object to be convertedpublic static BigInteger[] getBigIntegerArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBooleanObjectArray(Object value)
value
- Boolean[] to be convertedpublic static Boolean[] getBooleanObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromByteObjectArray(Object value)
value
- Byte[] to be convertedpublic static Byte[] getByteObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromCharObjectArray(Object value)
value
- Character array to be convertedpublic static Character[] getCharObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromDoubleObjectArray(Object value)
value
- Double array to be convertedpublic static Double[] getDoubleObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromFloatObjectArray(Object value)
value
- Float array to be convertedpublic static Float[] getFloatObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromIntObjectArray(Object value)
value
- Integer array to be convertedpublic static Integer[] getIntObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromLongObjectArray(Object value)
value
- Long array to be convertedpublic static Long[] getLongObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromShortObjectArray(Object value)
value
- Short array to be convertedpublic static Short[] getShortObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static Object convertTo(Object value, Class type)
value
- the value to be convertedtype
- the type of the expected object returned from the conversionpublic static byte[] getBytesFromInt(int val)
val
- The intpublic static byte[] getBytesFromShort(short val)
val
- The shortpublic static String getStringFromInt(int val)
val
- The intpublic static String getStringFromShort(short val)
val
- The shortpublic static String getHexFromInt(int val)
val
- The intpublic static String getHexFromShort(short val)
val
- The shortpublic static int getIntFromByteArray(byte[] bytes)
bytes
- The byte arraypublic static Timestamp stringToTimestamp(String s, Calendar cal)
s
- Timestamp stringcal
- The Calendar to use for conversionIllegalArgumentException
- Thrown if the format of the
String is invalidpublic static String timestampToString(Timestamp ts, Calendar cal)
ts
- The timestamp to be formatted.cal
- The CalendarTimestamp
public static int intFromString(String str, int dflt)
str
- The stringdflt
- The default valuepublic static JdbcType getJdbcTypeForEnum(AbstractMemberMetaData mmd, FieldRole role, ClassLoaderResolver clr)
public static Object getEnumForStoredValue(AbstractMemberMetaData mmd, FieldRole role, Object value, ClassLoaderResolver clr)
public static Object getStoredValueFromEnum(AbstractMemberMetaData mmd, FieldRole role, Enum myEnum)
mmd
- Metadata for the memberrole
- Role of the Enum in this membermyEnum
- The enumCopyright © 2018. All rights reserved.