|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
PRESENTATION - The presentation type. Must be compatible with what
getPresentationType() returns.MODEL - The model type. Must be compatible with what
getModelType() returns.public interface Converter<PRESENTATION,MODEL>
Interface that implements conversion between a model and a presentation type.
Typically convertToPresentation(Object, Class, Locale) and
convertToModel(Object, Class, Locale) should be symmetric so that
chaining these together returns the original result for all input but this is
not a requirement.
Converters must not have any side effects (never update UI from inside a converter).
All Converters must be stateless and thread safe.
If conversion of a value fails, a Converter.ConversionException is thrown.
| Nested Class Summary | |
|---|---|
static class |
Converter.ConversionException
An exception that signals that the value passed to convertToPresentation(Object, Class, Locale) or
convertToModel(Object, Class, Locale) could not be
converted. |
| Method Summary | |
|---|---|
MODEL |
convertToModel(PRESENTATION value,
java.lang.Class<? extends MODEL> targetType,
java.util.Locale locale)
Converts the given value from target type to source type. |
PRESENTATION |
convertToPresentation(MODEL value,
java.lang.Class<? extends PRESENTATION> targetType,
java.util.Locale locale)
Converts the given value from source type to target type. |
java.lang.Class<MODEL> |
getModelType()
The source type of the converter. |
java.lang.Class<PRESENTATION> |
getPresentationType()
The target type of the converter. |
| Method Detail |
|---|
MODEL convertToModel(PRESENTATION value,
java.lang.Class<? extends MODEL> targetType,
java.util.Locale locale)
throws Converter.ConversionException
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingconvertToPresentation(Object, Class, Locale) and
convertToModel(Object, Class, Locale) should return the original
value.
value - The value to convert, compatible with the target type. Can be
nulltargetType - The requested type of the return valuelocale - The locale to use for conversion. Can be null.
Converter.ConversionException - If the value could not be converted
PRESENTATION convertToPresentation(MODEL value,
java.lang.Class<? extends PRESENTATION> targetType,
java.util.Locale locale)
throws Converter.ConversionException
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingconvertToPresentation(Object, Class, Locale) and
convertToModel(Object, Class, Locale) should return the original
value.
value - The value to convert, compatible with the target type. Can be
nulltargetType - The requested type of the return valuelocale - The locale to use for conversion. Can be null.
Converter.ConversionException - If the value could not be convertedjava.lang.Class<MODEL> getModelType()
convertToPresentation(Object, Class, Locale).
java.lang.Class<PRESENTATION> getPresentationType()
convertToModel(Object, Class, Locale).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||