com.vaadin.data.util.converter
Class StringToNumberConverter
java.lang.Object
com.vaadin.data.util.converter.AbstractStringToNumberConverter<java.lang.Number>
com.vaadin.data.util.converter.StringToNumberConverter
- All Implemented Interfaces:
- Converter<java.lang.String,java.lang.Number>, java.io.Serializable
public class StringToNumberConverter
- extends AbstractStringToNumberConverter<java.lang.Number>
A converter that converts from Number
to String
and back.
Uses the given locale and NumberFormat
for formatting and parsing.
Override and overwrite AbstractStringToNumberConverter.getFormat(Locale)
to use a different format.
- Since:
- 7.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
Method Summary |
java.lang.Number |
convertToModel(java.lang.String value,
java.lang.Class<? extends java.lang.Number> targetType,
java.util.Locale locale)
Converts the given value from target type to source type. |
java.lang.Class<java.lang.Number> |
getModelType()
The source type of the converter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringToNumberConverter
public StringToNumberConverter()
convertToModel
public java.lang.Number convertToModel(java.lang.String value,
java.lang.Class<? extends java.lang.Number> targetType,
java.util.Locale locale)
throws Converter.ConversionException
- Description copied from interface:
Converter
- Converts 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 chaining
Converter.convertToPresentation(Object, Class, Locale)
and
Converter.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 java.lang.Class<java.lang.Number> getModelType()
- Description copied from interface:
Converter
- The source type of the converter.
Values of this type can be passed to
Converter.convertToPresentation(Object, Class, Locale)
.
- Returns:
- The source type
Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.