|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.data.util.converter.AbstractStringToNumberConverter<T>
public abstract class AbstractStringToNumberConverter<T>
A converter that converts from the number type T to String
and back.
Uses the given locale and NumberFormat
for formatting and parsing.
Automatically trims the input string, removing any leading and trailing white
space.
Override and overwrite getFormat(Locale)
to use a different format.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.vaadin.data.util.converter.Converter |
---|
Converter.ConversionException |
Constructor Summary | |
---|---|
AbstractStringToNumberConverter()
|
Method Summary | |
---|---|
protected java.lang.Number |
convertToNumber(java.lang.String value,
java.lang.Class<? extends java.lang.Number> targetType,
java.util.Locale locale)
Convert the value to a Number using the given locale and getFormat(Locale) . |
java.lang.String |
convertToPresentation(T value,
java.lang.Class<? extends java.lang.String> targetType,
java.util.Locale locale)
Converts the given value from source type to target type. |
protected java.text.NumberFormat |
getFormat(java.util.Locale locale)
Returns the format used by #convertToPresentation(Object, Locale)
and #convertToModel(Object, Locale) . |
java.lang.Class<java.lang.String> |
getPresentationType()
The target type of the converter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.data.util.converter.Converter |
---|
convertToModel, getModelType |
Constructor Detail |
---|
public AbstractStringToNumberConverter()
Method Detail |
---|
protected java.text.NumberFormat getFormat(java.util.Locale locale)
#convertToPresentation(Object, Locale)
and #convertToModel(Object, Locale)
.
locale
- The locale to use
protected java.lang.Number convertToNumber(java.lang.String value, java.lang.Class<? extends java.lang.Number> targetType, java.util.Locale locale) throws Converter.ConversionException
getFormat(Locale)
.
value
- The value to convertlocale
- The locale to use for conversion
ConversionException
- If there was a problem converting the value
Converter.ConversionException
public java.lang.String convertToPresentation(T value, java.lang.Class<? extends java.lang.String> targetType, java.util.Locale locale) throws Converter.ConversionException
Converter
A 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<java.lang.String,T>
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 java.lang.Class<java.lang.String> getPresentationType()
Converter
Converter.convertToModel(Object, Class, Locale)
.
getPresentationType
in interface Converter<java.lang.String,T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |