public abstract class AbstractConverter extends Object implements IConverter
Constructor and Description |
---|
AbstractConverter() |
Modifier and Type | Method and Description |
---|---|
Object |
convertArrayToString(Object o)
Converts an array to a String.
|
Object |
convertArrayToType(Class<?> type,
Object o)
Converts to an array of the specified type.
|
Collection<?> |
convertCollectionToString(Object o)
Converts a Collection to a String.
|
Collection<?> |
convertCollectionToType(Class<?> type,
Object o)
Converts to a Collection of the specified type.
|
protected ConvertException |
convertionException(Object value,
Class<?> targetType)
Convenience method to create a Conversion Exception.
|
protected ConvertException |
convertionException(Object value,
Class<?> targetType,
Exception e)
Convenience method to create a Conversion Exception with a cause.
|
String |
convertToString(Object o)
Returns the
internalConvertToString(Object) result on provided Object, or null if object is null. |
<T> T |
convertToType(Class<T> type,
Object o)
Converts the object to the specified type.
|
protected String |
internalConvertToString(Object o)
Returns the default "toString" result on provided Object.
|
protected abstract <T> T |
internalConvertToType(Class<T> type,
Object o)
Handles conversion to an handled type.
|
Object |
stringConversion(Object o)
Chooses beetween
convertToString(Object) , convertArrayToString(Object) and convertCollectionToString(Object)
depending on the object type. |
String |
toString()
Name of the converter, by default its class name (not qualified).
|
Object |
typeConversion(Class<?> type,
Object o)
Chooses beetween
convertToType(Class, Object) , convertArrayToType(Class, Object) and convertCollectionToType(Class, Object)
depending on the object type. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTypes
public Object stringConversion(Object o) throws UtilsException
convertToString(Object)
, convertArrayToString(Object)
and convertCollectionToString(Object)
depending on the object type.stringConversion
in interface IConverter
UtilsException
public String convertToString(Object o) throws UtilsException
internalConvertToString(Object)
result on provided Object, or null if object is null.convertToString
in interface IConverter
UtilsException
public Object convertArrayToString(Object o) throws UtilsException
convertArrayToString
in interface IConverter
UtilsException
public Collection<?> convertCollectionToString(Object o) throws UtilsException
convertCollectionToString
in interface IConverter
UtilsException
protected String internalConvertToString(Object o) throws UtilsException
UtilsException
public Object typeConversion(Class<?> type, Object o) throws UtilsException
convertToType(Class, Object)
, convertArrayToType(Class, Object)
and convertCollectionToType(Class, Object)
depending on the object type.typeConversion
in interface IConverter
UtilsException
public <T> T convertToType(Class<T> type, Object o) throws UtilsException
convertToType
in interface IConverter
UtilsException
public Object convertArrayToType(Class<?> type, Object o) throws UtilsException
convertArrayToType
in interface IConverter
UtilsException
public Collection<?> convertCollectionToType(Class<?> type, Object o) throws UtilsException
convertCollectionToType
in interface IConverter
UtilsException
protected abstract <T> T internalConvertToType(Class<T> type, Object o) throws UtilsException
UtilsException
protected ConvertException convertionException(Object value, Class<?> targetType)
protected ConvertException convertionException(Object value, Class<?> targetType, Exception e)