org.mentawai.converter
Class LocaleConverter

java.lang.Object
  extended by org.mentawai.converter.LocaleConverter
All Implemented Interfaces:
Converter
Direct Known Subclasses:
DateConverter

public abstract class LocaleConverter
extends Object
implements Converter

A converter that needs to know the user locale to perform the conversion. You should override this class to implement your own converters.

Author:
Sergio Oliveira

Constructor Summary
LocaleConverter()
           
 
Method Summary
protected  boolean allowNull()
          Override this method if you want to convert null (not-present) values.
abstract  Object convert(Object value, Locale loc)
          Convert an object to another one using the use locale.
 Object convert(String field, Action action)
          Converts a input field from this action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleConverter

public LocaleConverter()
Method Detail

convert

public abstract Object convert(Object value,
                               Locale loc)
                        throws ConversionException
Convert an object to another one using the use locale.

Parameters:
value - The object to convert.
loc - The user locale to use in the convertion.
Returns:
The new object converted.
Throws:
ConversionException - if the conversion fail for any reason.

allowNull

protected boolean allowNull()
Override this method if you want to convert null (not-present) values. Default is FALSE.

Returns:
If this converter should try to convert NULL values.
Since:
1.11

convert

public Object convert(String field,
                      Action action)
               throws ConversionException
Description copied from interface: Converter
Converts a input field from this action.

Specified by:
convert in interface Converter
Parameters:
field - The field to convert.
action - The action from where to get the field.
Returns:
The field value converted.
Throws:
ConversionException - if the field value cannot be converted.


Copyright © 2013. All Rights Reserved.