@AlfrescoPublicApi public class TypeConverter extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
TypeConverter.Converter<F,T>
Conversion interface
|
protected class |
TypeConverter.DynamicTwoStageConverter<F,I,T>
Support for chaining conversions
|
static class |
TypeConverter.TwoStageConverter<F,I,T>
Support for chaining conversions
|
Constructor and Description |
---|
TypeConverter() |
Modifier and Type | Method and Description |
---|---|
<F,T> void |
addConverter(Class<F> source,
Class<T> destination,
TypeConverter.Converter<F,T> converter)
Add a converter to the list of those available
|
<F,I,T> TypeConverter.Converter<F,T> |
addDynamicTwoStageConverter(Class<F> source,
Class<I> intermediate,
Class<T> destination)
Add a dynamic two stage converter
|
boolean |
booleanValue(Object value)
Get the boolean value for the value object
May have conversion failure
|
byte |
byteValue(Object value)
Get the byte value for the value object
May have conversion failure
|
char |
charValue(Object value)
Get the char value for the value object
May have conversion failure
|
<T> Collection<T> |
convert(Class<T> c,
Collection<?> values)
General conversion method to convert collection contents to the specified
type.
|
<T> T |
convert(Class<T> c,
Object value)
General conversion method to Object types (note it cannot support
conversion to primary types due the restrictions of reflection.
|
Collection<?> |
convert(DataTypeDefinition propertyType,
Collection<?> values)
General conversion method to convert collection contents to the specified
type.
|
Object |
convert(DataTypeDefinition propertyType,
Object value)
General conversion method to Object types (note it cannot support
conversion to primary types due the restrictions of reflection.
|
Collection<?> |
convert(DataTypeDefinition propertyType,
Object[] values)
General conversion method to convert collection contents to the specified
type.
|
double |
doubleValue(Object value)
Get the bollean value for the value object
May have conversion failure
|
float |
floatValue(Object value)
Get the bollean value for the value object
May have conversion failure
|
<T> Collection<T> |
getCollection(Class<T> c,
Object value)
Get a collection for the passed value converted to the specified type
|
<F,T> TypeConverter.Converter<F,T> |
getConverter(Class<F> source,
Class<T> dest)
Find a conversion for a specific Class
|
<T> TypeConverter.Converter<Object,T> |
getConverter(Object value,
Class<T> dest)
Find conversion for the specified object
Note: Takes into account the class of the object and any interfaces it may
also support.
|
Map<Class<?>,Map<Class<?>,TypeConverter.Converter<?,?>>> |
getConverters() |
int |
intValue(Object value)
Get the int value for the value object
May have conversion failure
|
boolean |
isMultiValued(Object value)
Is the value multi valued
|
long |
longValue(Object value)
Get the long value for the value object
May have conversion failure
|
short |
shortValue(Object value)
Get the short value for the value object
May have conversion failure
|
int |
size(Object value)
Get the number of values represented
|
public final Object convert(DataTypeDefinition propertyType, Object value)
propertyType
- - the target property typevalue
- - the value to be convertedpublic final <T> T convert(Class<T> c, Object value)
T
- The target type for the result of the conversionc
- - a class for the target typevalue
- - the value to be convertedTypeConversionException
- if the conversion cannot be performedpublic final Collection<?> convert(DataTypeDefinition propertyType, Object[] values)
propertyType
- - the target property typevalues
- - the value to be convertedDictionaryException
- if the property type's registered java class is invalidTypeConversionException
- if the conversion cannot be performedpublic final Collection<?> convert(DataTypeDefinition propertyType, Collection<?> values)
propertyType
- - the target property typevalues
- - the value to be convertedDictionaryException
- if the property type's registered java class is invalidTypeConversionException
- if the conversion cannot be performedpublic final <T> Collection<T> convert(Class<T> c, Collection<?> values)
T
- The target type for the result of the conversionc
- - a class for the target typevalues
- - the collection to be convertedTypeConversionException
- if the conversion cannot be performedpublic final boolean booleanValue(Object value)
value
- Objectpublic final char charValue(Object value)
value
- Objectpublic final byte byteValue(Object value)
value
- Objectpublic final short shortValue(Object value)
value
- Objectpublic final int intValue(Object value)
value
- Objectpublic final long longValue(Object value)
value
- Objectpublic final float floatValue(Object value)
value
- Objectpublic final double doubleValue(Object value)
value
- Objectpublic final boolean isMultiValued(Object value)
value
- Objectpublic final int size(Object value)
value
- Objectpublic final <T> Collection<T> getCollection(Class<T> c, Object value)
value
- Objectpublic final <F,T> void addConverter(Class<F> source, Class<T> destination, TypeConverter.Converter<F,T> converter)
public final <F,I,T> TypeConverter.Converter<F,T> addDynamicTwoStageConverter(Class<F> source, Class<I> intermediate, Class<T> destination)
public final <T> TypeConverter.Converter<Object,T> getConverter(Object value, Class<T> dest)
public Map<Class<?>,Map<Class<?>,TypeConverter.Converter<?,?>>> getConverters()
public <F,T> TypeConverter.Converter<F,T> getConverter(Class<F> source, Class<T> dest)
Copyright © 2005–2018 Alfresco Software. All rights reserved.