TYPE - Type of the data being converted.public class DesignToStringConverter<TYPE> extends Object implements Converter<String,TYPE>
DesignAttributeHandler that deals with converting
various types to string.Converter.ConversionException| Modifier and Type | Field and Description |
|---|---|
static String |
NULL_VALUE_REPRESENTATION
A string that corresponds to how a null value is stored.
|
| Constructor and Description |
|---|
DesignToStringConverter(Class<? extends TYPE> type)
Constructs the converter for a given type.
|
DesignToStringConverter(Class<? extends TYPE> type,
String staticMethodName)
Constructs the converter for a given type, giving the name of the public
static method that does the conversion from String.
|
| Modifier and Type | Method and Description |
|---|---|
TYPE |
convertToModel(String value,
Class<? extends TYPE> targetType,
Locale locale)
Converts the given value from target type to source type.
|
String |
convertToPresentation(TYPE value,
Class<? extends String> targetType,
Locale locale)
Converts the given value from source type to target type.
|
Class<TYPE> |
getModelType()
The source type of the converter.
|
Class<String> |
getPresentationType()
The target type of the converter.
|
public static final String NULL_VALUE_REPRESENTATION
public DesignToStringConverter(Class<? extends TYPE> type)
valueOf(String) is present in the type to do the
conversion.type - Type of values to convert.public DesignToStringConverter(Class<? extends TYPE> type, String staticMethodName)
type - Type to convert.staticMethodName - Method to call when converting from String to this type. This
must be public and static method that returns an object of
passed type.public TYPE convertToModel(String value, Class<? extends TYPE> targetType, Locale locale) throws Converter.ConversionException
ConverterA converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale) and
Converter.convertToModel(Object, Class, Locale) should return the original
value.convertToModel in interface Converter<String,TYPE>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 convertedpublic String convertToPresentation(TYPE value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException
ConverterA converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale) and
Converter.convertToModel(Object, Class, Locale) should return the original
value.convertToPresentation in interface Converter<String,TYPE>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 convertedpublic Class<TYPE> getModelType()
ConverterConverter.convertToPresentation(Object, Class, Locale).getModelType in interface Converter<String,TYPE>public Class<String> getPresentationType()
ConverterConverter.convertToModel(Object, Class, Locale).getPresentationType in interface Converter<String,TYPE>Copyright © 2016 Vaadin Ltd. All rights reserved.