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 Object |
getBigDecimalArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
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 Object |
getBooleanArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
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 Object |
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 Object |
getCharArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getCharObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getDoubleArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getDoubleObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getFloatArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
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 Object |
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 Object |
getIntObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getLongArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getLongObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getShortArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
static Object |
getShortObjectArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
|
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 Object getBooleanArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBooleanArray(Object value)
value
- Object to be convertedpublic static Object getCharArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromCharArray(Object value)
value
- Object to be convertedpublic static Object getDoubleArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromDoubleArray(Object value)
value
- Object to be convertedpublic static Object getFloatArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromFloatArray(Object value)
value
- Object to be convertedpublic static Object getIntArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromIntArray(Object value)
value
- Object to be convertedpublic static Object getLongArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromLongArray(Object value)
value
- Object to be convertedpublic static Object 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 Object getBigDecimalArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBigIntegerArray(Object value)
value
- Object to be convertedpublic static Object getBigIntegerArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromBooleanObjectArray(Object value)
value
- Boolean[] to be convertedpublic static Object getBooleanObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromByteObjectArray(Object value)
value
- Byte[] to be convertedpublic static Object getByteObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromCharObjectArray(Object value)
value
- Character array to be convertedpublic static Object getCharObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromDoubleObjectArray(Object value)
value
- Double array to be convertedpublic static Object getDoubleObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromFloatObjectArray(Object value)
value
- Float array to be convertedpublic static Object getFloatObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromIntObjectArray(Object value)
value
- Integer array to be convertedpublic static Object getIntObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromLongObjectArray(Object value)
value
- Long array to be convertedpublic static Object getLongObjectArrayFromByteArray(byte[] buf)
buf
- byte array to be convertedpublic static byte[] getByteArrayFromShortObjectArray(Object value)
value
- Short array to be convertedpublic static Object 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 valueCopyright © 2019. All rights reserved.