|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
MODEL
- The model type. Must be compatible with what
getModelType()
returns.PRESENTATION
- The presentation type. Must be compatible with what
getPresentationType()
returns.public interface Converter<PRESENTATION,MODEL>
Interface that implements conversion between a model and a presentation type.
Typically convertToPresentation(Object, Locale)
and
convertToModel(Object, 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, Locale) or
convertToModel(Object, Locale) could not be converted. |
Method Summary | |
---|---|
MODEL |
convertToModel(PRESENTATION value,
java.util.Locale locale)
Converts the given value from target type to source type. |
PRESENTATION |
convertToPresentation(MODEL value,
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.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, Locale)
and
convertToModel(Object, Locale)
should return the original value.
value
- The value to convert, compatible with the target type. Can be
nulllocale
- The locale to use for conversion. Can be null.
Converter.ConversionException
- If the value could not be convertedPRESENTATION convertToPresentation(MODEL value, 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, Locale)
and
convertToModel(Object, Locale)
should return the original value.
value
- The value to convert, compatible with the target type. Can be
nulllocale
- The locale to use for conversion. Can be null.
Converter.ConversionException
- If the value could not be convertedjava.lang.Class<MODEL> getModelType()
convertToPresentation(Object, Locale)
.
java.lang.Class<PRESENTATION> getPresentationType()
convertToModel(Object, Locale)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |