org.vostok.vaadin.addon.converter
Class NumberConverter

java.lang.Object
  extended by org.vostok.vaadin.addon.converter.NumberConverter
All Implemented Interfaces:
com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>, java.io.Serializable

public class NumberConverter
extends java.lang.Object
implements com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>

Translate a String from/to Double.
It accept soft or strict format, double or integer infoncement. Meant to be used with NumberModel

Since:
1.1
Author:
levreau.jerome@vostoksystem.eu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.util.converter.Converter
com.vaadin.data.util.converter.Converter.ConversionException
 
Constructor Summary
NumberConverter()
          Default NumberConverter, strict format, no error message, plain integer.
NumberConverter(boolean soft, java.lang.String message)
          NumberConverter with plain integer
NumberConverter(boolean soft, java.lang.String message, boolean integer)
          Convert input string to Number (Double).
 
Method Summary
 java.lang.Double convertToModel(java.lang.String value, java.lang.Class<? extends java.lang.Double> targetType, java.util.Locale locale)
           
 java.lang.String convertToPresentation(java.lang.Double value, java.lang.Class<? extends java.lang.String> targetType, java.util.Locale locale)
           
 java.lang.Class<java.lang.Double> getModelType()
           
 java.lang.Class<java.lang.String> getPresentationType()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberConverter

public NumberConverter()
Default NumberConverter, strict format, no error message, plain integer.
note input will still accept blank char and will be trimmed


NumberConverter

public NumberConverter(boolean soft,
                       java.lang.String message)
NumberConverter with plain integer

Parameters:
soft -
message -

NumberConverter

public NumberConverter(boolean soft,
                       java.lang.String message,
                       boolean integer)
Convert input string to Number (Double). Input will be trimmed.
If soft is true accept any king of string and will extract the first length of digit from it.

Parameters:
soft -
message - message to display on error. null for none.
integer - true will only accept integer number. If soft is true, decimal digt will be ignored
Method Detail

convertToModel

public java.lang.Double convertToModel(java.lang.String value,
                                       java.lang.Class<? extends java.lang.Double> targetType,
                                       java.util.Locale locale)
                                throws com.vaadin.data.util.converter.Converter.ConversionException
Specified by:
convertToModel in interface com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>
Parameters:
value -
targetType -
locale -
Returns:
Throws:
com.vaadin.data.util.converter.Converter.ConversionException

convertToPresentation

public java.lang.String convertToPresentation(java.lang.Double value,
                                              java.lang.Class<? extends java.lang.String> targetType,
                                              java.util.Locale locale)
                                       throws com.vaadin.data.util.converter.Converter.ConversionException
Specified by:
convertToPresentation in interface com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>
Parameters:
value -
targetType -
locale -
Returns:
Throws:
com.vaadin.data.util.converter.Converter.ConversionException

getModelType

public java.lang.Class<java.lang.Double> getModelType()
Specified by:
getModelType in interface com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>
Returns:

getPresentationType

public java.lang.Class<java.lang.String> getPresentationType()
Specified by:
getPresentationType in interface com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Double>
Returns: