Package com.vaadin.data.util.converter
Class StringToShortConverter
- java.lang.Object
-
- com.vaadin.data.util.converter.AbstractStringToNumberConverter<Short>
-
- com.vaadin.data.util.converter.StringToShortConverter
-
- All Implemented Interfaces:
Converter<String,Short>,Serializable
public class StringToShortConverter extends AbstractStringToNumberConverter<Short>
A converter that converts fromStringtoShortand back. Uses the given locale and aNumberFormatinstance for formatting and parsing.Override and overwrite
getFormat(Locale)to use a different format.- Since:
- 7.4
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.data.util.converter.Converter
Converter.ConversionException
-
-
Constructor Summary
Constructors Constructor Description StringToShortConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShortconvertToModel(String value, Class<? extends Short> targetType, Locale locale)Converts the given value from target type to source type.protected NumberFormatgetFormat(Locale locale)Returns the format used by#convertToPresentation(Short, Class, Locale)andconvertToModel(String, Class, Locale)Class<Short>getModelType()The source type of the converter.-
Methods inherited from class com.vaadin.data.util.converter.AbstractStringToNumberConverter
convertToNumber, convertToPresentation, getPresentationType
-
-
-
-
Method Detail
-
getFormat
protected NumberFormat getFormat(Locale locale)
Returns the format used by#convertToPresentation(Short, Class, Locale)andconvertToModel(String, Class, Locale)- Overrides:
getFormatin classAbstractStringToNumberConverter<Short>- Parameters:
locale- The locale to use- Returns:
- A NumberFormat instance
-
convertToModel
public Short convertToModel(String value, Class<? extends Short> targetType, Locale locale) throws Converter.ConversionException
Description copied from interface:ConverterConverts the given value from target type to source type.A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)andConverter.convertToModel(Object, Class, Locale)should return the original value.- Parameters:
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.- Returns:
- The converted value compatible with the source type
- Throws:
Converter.ConversionException- If the value could not be converted
-
getModelType
public Class<Short> getModelType()
Description copied from interface:ConverterThe source type of the converter. Values of this type can be passed toConverter.convertToPresentation(Object, Class, Locale).- Returns:
- The source type
-
-