com.vaadin.data.util.converter
Class StringToLongConverter

java.lang.Object
  extended by com.vaadin.data.util.converter.AbstractStringToNumberConverter<java.lang.Long>
      extended by com.vaadin.data.util.converter.StringToLongConverter
All Implemented Interfaces:
Converter<java.lang.String,java.lang.Long>, java.io.Serializable

public class StringToLongConverter
extends AbstractStringToNumberConverter<java.lang.Long>

A converter that converts from String to Long and back. Uses the given locale and a NumberFormat instance for formatting and parsing.

Override and overwrite getFormat(Locale) to use a different format.

Since:
7.2
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
StringToLongConverter()
           
 
Method Summary
 java.lang.Long convertToModel(java.lang.String value, java.lang.Class<? extends java.lang.Long> targetType, java.util.Locale locale)
          Converts the given value from target type to source type.
protected  java.text.NumberFormat getFormat(java.util.Locale locale)
          Returns the format used by #convertToPresentation(Long, Class, Locale) and convertToModel(String, Class, Locale)
 java.lang.Class<java.lang.Long> getModelType()
          The source type of the converter.
 
Methods inherited from class com.vaadin.data.util.converter.AbstractStringToNumberConverter
convertToNumber, convertToPresentation, getPresentationType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringToLongConverter

public StringToLongConverter()
Method Detail

getFormat

protected java.text.NumberFormat getFormat(java.util.Locale locale)
Returns the format used by #convertToPresentation(Long, Class, Locale) and convertToModel(String, Class, Locale)

Overrides:
getFormat in class AbstractStringToNumberConverter<java.lang.Long>
Parameters:
locale - The locale to use
Returns:
A NumberFormat instance

convertToModel

public java.lang.Long convertToModel(java.lang.String value,
                                     java.lang.Class<? extends java.lang.Long> 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 null
targetType - The requested type of the return value
locale - 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.Long> 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-2014 Vaadin Ltd. All Rights Reserved.