|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gentics.api.lib.etc.ObjectTransformer
public final class ObjectTransformer
Helper class to transform objects into specific types (classes).
Nested Class Summary | |
---|---|
static class |
ObjectTransformer.InputStreamReaderRunnable
Helper class that extends Runnable to read data from an input stream in a separate thread |
Field Summary | |
---|---|
protected static org.apache.log4j.Logger |
logger
the logger |
Method Summary | |
---|---|
static int |
compareObjects(Comparable first,
Comparable second,
boolean nullfirst)
Compare objects, care also for null objects |
static byte[] |
decodeBinary(String encoded)
Decode the encoded binary data (hexcode, leading zeros, all uppercase letters) |
static String |
encodeBinary(byte[] binaryData)
Encode the given binary data into hexcode (leading zeros, all uppercase letters) |
static byte[] |
getBinary(Object o,
byte[] defaultValue)
Get the object as binary value (byte array) |
static boolean |
getBoolean(Object o,
boolean defaultValue)
Get the boolean value of the given object. true, 1, yes and on will be interpreted as TRUE. false, 0, no and off will be interpreted as FALSE. Everything else cannot be interpreted as boolean and will return the defaultValue. |
static Boolean |
getBoolean(Object o,
Boolean defaultValue)
Get the Boolean value of the given object. true, 1, yes and on will be interpreted as TRUE. false, 0, no and off will be interpreted as FALSE. Everything else cannot be interpreted as boolean and will return the defaultValue. |
static Collection |
getCollection(Object o,
Collection defaultValue)
Get the given object as a collection. |
static Date |
getDate(Object o,
Date defaultValue)
Get the Date representation of the given object |
static double |
getDouble(Object o,
double defaultValue)
Get a double value of the given object |
static Double |
getDouble(Object o,
Double defaultValue)
Get the Double representation of the object |
static int |
getInt(Object o,
int defaultValue)
Get an integer representation of the given object |
static Integer |
getInteger(Object o,
Integer defaultValue)
Get the Integer representation of the given object |
static long |
getLong(Object o,
long defaultValue)
Get a long representation of the given object |
static Long |
getLong(Object o,
Long defaultValue)
Get a Long representation of the given object |
static long |
getLongTimestamp(Object object,
long defaultValue)
Get the timestamp in milliseconds of the object (if it is a Date) or the defaultValue for non-Date objects |
static Number |
getNumber(Object object,
Number defaultValue)
Get the number represented by the given object |
static String |
getString(Object o,
String defaultValue)
Transform the given object into a string (its string representation) |
static String[] |
getStringArray(Object o,
String[] defaultValue)
Transform the given object into a string array |
static int |
getTimestamp(Object object,
int defaultValue)
Get the timestamp value of the object (if it is a Date) or the defaultValue for non-Date objects |
static String |
getToken(Object o,
String defaultValue)
Transform the given object into a token. |
static boolean |
isEmpty(Object value)
Check whether the given value somehow is empty. |
static String |
readInputStreamIntoString(InputStream inputStream)
Read data coming from the given input stream, using the default charset. |
static String |
readInputStreamIntoString(InputStream inputStream,
String charset)
Read data coming from the given input stream, using the given charset. |
static Object |
transformObject(Object baseObject,
Class targetClass)
Tries to transforms a given object to the specified class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.log4j.Logger logger
Method Detail |
---|
public static Collection getCollection(Object o, Collection defaultValue)
List
Vector
containing the given object is returned
o
- object to get as collectiondefaultValue
- default value
public static int getInt(Object o, int defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have an
integer representation)
public static Integer getInteger(Object o, Integer defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have an
Integer representation)
public static long getLong(Object o, long defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a long
representation)
public static Long getLong(Object o, Long defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a Long
representation)
public static double getDouble(Object o, double defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a double
representation)
public static Double getDouble(Object o, Double defaultValue)
o
- object to transformdefaultValue
- default value
public static boolean getBoolean(Object o, boolean defaultValue)
o
- object to transformdefaultValue
- default value (when the object cannot be interpreted
as boolean)
public static Boolean getBoolean(Object o, Boolean defaultValue)
o
- object to transformdefaultValue
- default value (when the object cannot be interpreted
as boolean)
public static byte[] getBinary(Object o, byte[] defaultValue)
o
- object to transformdefaultValue
- default value
public static String getString(Object o, String defaultValue)
o
- object to transformdefaultValue
- default value (when the object is null)
public static String[] getStringArray(Object o, String[] defaultValue)
o
- object to transformdefaultValue
- default value, when the object cannot be interpreted as string array
public static Date getDate(Object o, Date defaultValue)
o
- object to transformdefaultValue
- default value
public static String getToken(Object o, String defaultValue)
o
- object to transformdefaultValue
- default value (when the object is null)
public static boolean isEmpty(Object value)
value
- value to check for emptyness
public static String encodeBinary(byte[] binaryData)
binaryData
- binary data to encode
public static byte[] decodeBinary(String encoded)
encoded
- encoded binary data
IllegalArgumentException
- if the encoded data cannot be decodedpublic static int getTimestamp(Object object, int defaultValue)
object
- Date objectdefaultValue
- default value
public static long getLongTimestamp(Object object, long defaultValue)
object
- Date objectdefaultValue
- default value
public static Number getNumber(Object object, Number defaultValue)
object
- object to transform into a numberdefaultValue
- defaultvalue when object is null, or does not represent a number
public static Object transformObject(Object baseObject, Class targetClass)
baseObject
- The base object which to transformtargetClass
- The target class to which the baseObect shall be transformed.
public static String readInputStreamIntoString(InputStream inputStream) throws IOException
inputStream
- input stream containing data
IOException
public static String readInputStreamIntoString(InputStream inputStream, String charset) throws IOException
inputStream
- input stream containing datacharset
- charset to be used
IOException
public static int compareObjects(Comparable first, Comparable second, boolean nullfirst)
first
- first objectsecond
- second objectnullfirst
- true when nulls shall be smaller than nonnulls, false if
nulls are bigger
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |