public class

DefaultObjectStringConverter

extends ConvertUtilsObjectStringConverter
java.lang.Object
   ↳ org.apache.commons.betwixt.strategy.ObjectStringConverter
     ↳ org.apache.commons.betwixt.strategy.ConvertUtilsObjectStringConverter
       ↳ org.apache.commons.betwixt.strategy.DefaultObjectStringConverter

Class Overview

Default string <-> object conversion strategy.

This delegates to ConvertUtils except when the type is assignable from java.util.Date but not from java.sql.Date. In this case, the format used is (in SimpleDateFormat terms) EEE MMM dd HH:mm:ss zzz yyyy. This is the same as the output of the toString method on java.util.Date.

This should preserve the existing symantic behaviour whilst allowing round tripping of dates (given the default settings).

Summary

[Expand]
Inherited Constants
From class org.apache.commons.betwixt.strategy.ObjectStringConverter
Public Constructors
DefaultObjectStringConverter()
Public Methods
String objectToString(Object object, Class type, String flavour, Context context)
This method is deprecated. 0.7 use objectToString(Object, Class, Context) instead. The preferred way to support flavours is by setting the org.apache.commons.betwixt.FLAVOUR option. This can then be retrieved by calling getOptions()
Object stringToObject(String value, Class type, String flavour, Context context)
This method is deprecated. 0.7 use stringToObject(String, Class, Context) instead. The preferred way to support flavours is by setting the org.apache.commons.betwixt.FLAVOUR option. This can then be retrieved by calling getOptions()
Protected Methods
void handleException(Exception e)
Allow subclasses to use a different exception handling strategy.
[Expand]
Inherited Methods
From class org.apache.commons.betwixt.strategy.ConvertUtilsObjectStringConverter
From class org.apache.commons.betwixt.strategy.ObjectStringConverter
From class java.lang.Object

Public Constructors

public DefaultObjectStringConverter ()

Public Methods

public String objectToString (Object object, Class type, String flavour, Context context)

This method is deprecated.
0.7 use objectToString(Object, Class, Context) instead. The preferred way to support flavours is by setting the org.apache.commons.betwixt.FLAVOUR option. This can then be retrieved by calling getOptions()

Converts an object to a string representation using ConvertUtils. If the object is a java.util.Date and the type is java.util.Date but not java.sql.Date then SimpleDateFormat formatting to EEE MMM dd HH:mm:ss zzz yyyy will be used. (This is the same as java.util.Date toString would return.)

Parameters
object the object to be converted, possibly null
type the property class of the object, not null
flavour a string allow symantic differences in formatting to be communicated (ignored)
context convert against this context not null
Returns
  • a String representation, not null

public Object stringToObject (String value, Class type, String flavour, Context context)

This method is deprecated.
0.7 use stringToObject(String, Class, Context) instead. The preferred way to support flavours is by setting the org.apache.commons.betwixt.FLAVOUR option. This can then be retrieved by calling getOptions()

Converts an object to a string representation using ConvertUtils.

Parameters
value the String to be converted, not null
type the property class to be returned (if possible), not null
flavour a string allow symantic differences in formatting to be communicated (ignored)
context not null
Returns
  • an Object converted from the String, not null

Protected Methods

protected void handleException (Exception e)

Allow subclasses to use a different exception handling strategy. This class throws a org.apache.commons.beanutils.ConversionException when conversion fails.

Parameters
e the Exception to be handled
Throws
ConversionException when conversion fails