|
||||||||||
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(java.lang.Comparable first,
java.lang.Comparable second,
boolean nullfirst)
Compare objects, care also for null objects |
static byte[] |
decodeBinary(java.lang.String encoded)
Decode the encoded binary data (hexcode, leading zeros, all uppercase letters) |
static java.lang.String |
encodeBinary(byte[] binaryData)
Encode the given binary data into hexcode (leading zeros, all uppercase letters) |
static byte[] |
getBinary(java.lang.Object o,
byte[] defaultValue)
Get the object as binary value (byte array) |
static boolean |
getBoolean(java.lang.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 java.lang.Boolean |
getBoolean(java.lang.Object o,
java.lang.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 java.util.Collection |
getCollection(java.lang.Object o,
java.util.Collection defaultValue)
Get the given object as a collection. |
static java.util.Date |
getDate(java.lang.Object o,
java.util.Date defaultValue)
Get the Date representation of the given object |
static double |
getDouble(java.lang.Object o,
double defaultValue)
Get a double value of the given object |
static java.lang.Double |
getDouble(java.lang.Object o,
java.lang.Double defaultValue)
Get the Double representation of the object |
static int |
getInt(java.lang.Object o,
int defaultValue)
Get an integer representation of the given object |
static java.lang.Integer |
getInteger(java.lang.Object o,
java.lang.Integer defaultValue)
Get the Integer representation of the given object |
static long |
getLong(java.lang.Object o,
long defaultValue)
Get a long representation of the given object |
static java.lang.Long |
getLong(java.lang.Object o,
java.lang.Long defaultValue)
Get a Long representation of the given object |
static long |
getLongTimestamp(java.lang.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 java.lang.Number |
getNumber(java.lang.Object object,
java.lang.Number defaultValue)
Get the number represented by the given object |
static java.lang.String |
getString(java.lang.Object o,
java.lang.String defaultValue)
Transform the given object into a string (its string representation) |
static java.lang.String[] |
getStringArray(java.lang.Object o,
java.lang.String[] defaultValue)
Transform the given object into a string array |
static int |
getTimestamp(java.lang.Object object,
int defaultValue)
Get the timestamp value of the object (if it is a Date) or the defaultValue for non-Date objects |
static java.lang.String |
getToken(java.lang.Object o,
java.lang.String defaultValue)
Transform the given object into a token. |
static boolean |
isEmpty(java.lang.Object value)
Check whether the given value somehow is empty. |
static java.lang.String |
readInputStreamIntoString(java.io.InputStream inputStream)
Read data coming from the given input stream, using the default charset. |
static java.lang.String |
readInputStreamIntoString(java.io.InputStream inputStream,
java.lang.String charset)
Read data coming from the given input stream, using the given charset. |
static java.lang.Object |
transformObject(java.lang.Object baseObject,
java.lang.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 java.util.Collection getCollection(java.lang.Object o, java.util.Collection defaultValue)
List
Vector
containing the given object is returned
o
- object to get as collectiondefaultValue
- default value
public static int getInt(java.lang.Object o, int defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have an
integer representation)
public static java.lang.Integer getInteger(java.lang.Object o, java.lang.Integer defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have an
Integer representation)
public static long getLong(java.lang.Object o, long defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a long
representation)
public static java.lang.Long getLong(java.lang.Object o, java.lang.Long defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a Long
representation)
public static double getDouble(java.lang.Object o, double defaultValue)
o
- object to transformdefaultValue
- default value (when the object does not have a double
representation)
public static java.lang.Double getDouble(java.lang.Object o, java.lang.Double defaultValue)
o
- object to transformdefaultValue
- default value
public static boolean getBoolean(java.lang.Object o, boolean defaultValue)
o
- object to transformdefaultValue
- default value (when the object cannot be interpreted
as boolean)
public static java.lang.Boolean getBoolean(java.lang.Object o, java.lang.Boolean defaultValue)
o
- object to transformdefaultValue
- default value (when the object cannot be interpreted
as boolean)
public static byte[] getBinary(java.lang.Object o, byte[] defaultValue)
o
- object to transformdefaultValue
- default value
public static java.lang.String getString(java.lang.Object o, java.lang.String defaultValue)
o
- object to transformdefaultValue
- default value (when the object is null)
public static java.lang.String[] getStringArray(java.lang.Object o, java.lang.String[] defaultValue)
o
- object to transformdefaultValue
- default value, when the object cannot be interpreted as string array
public static java.util.Date getDate(java.lang.Object o, java.util.Date defaultValue)
o
- object to transformdefaultValue
- default value
public static java.lang.String getToken(java.lang.Object o, java.lang.String defaultValue)
o
- object to transformdefaultValue
- default value (when the object is null)
public static boolean isEmpty(java.lang.Object value)
value
- value to check for emptyness
public static java.lang.String encodeBinary(byte[] binaryData)
binaryData
- binary data to encode
public static byte[] decodeBinary(java.lang.String encoded)
encoded
- encoded binary data
java.lang.IllegalArgumentException
- if the encoded data cannot be decodedpublic static int getTimestamp(java.lang.Object object, int defaultValue)
object
- Date objectdefaultValue
- default value
public static long getLongTimestamp(java.lang.Object object, long defaultValue)
object
- Date objectdefaultValue
- default value
public static java.lang.Number getNumber(java.lang.Object object, java.lang.Number defaultValue)
object
- object to transform into a numberdefaultValue
- defaultvalue when object is null, or does not represent a number
public static java.lang.Object transformObject(java.lang.Object baseObject, java.lang.Class targetClass)
baseObject
- The base object which to transformtargetClass
- The target class to which the baseObect shall be transformed.
public static java.lang.String readInputStreamIntoString(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- input stream containing data
java.io.IOException
public static java.lang.String readInputStreamIntoString(java.io.InputStream inputStream, java.lang.String charset) throws java.io.IOException
inputStream
- input stream containing datacharset
- charset to be used
java.io.IOException
public static int compareObjects(java.lang.Comparable first, java.lang.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 |