org.mentawai.converter
Class BasicConverter

java.lang.Object
  extended by org.mentawai.converter.BasicConverter
All Implemented Interfaces:
Converter
Direct Known Subclasses:
BooleanConverter, DoubleConverter, IntegerConverter, NullConverter, SQLToUtilDataConverter, SQLToUtilDateConverter, UtilToSQLDateConverter

public abstract class BasicConverter
extends Object
implements Converter

The simplest form of a converter that takes an object and convert it to another one. You should override this class to implement your own converters.

Author:
Sergio Oliveira

Constructor Summary
BasicConverter()
           
 
Method Summary
protected  boolean allowNull()
          Override this method if you want to convert null (not-present) values.
abstract  Object convert(Object value)
          Converts an object to another one.
 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

BasicConverter

public BasicConverter()
Method Detail

convert

public abstract Object convert(Object value)
                        throws ConversionException
Converts an object to another one. Implement this method with the convertion logic.

Parameters:
value - The object to convert.
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.