|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.betwixt.strategy.ObjectStringConverter
org.apache.commons.betwixt.strategy.ConvertUtilsObjectStringConverter
org.apache.commons.betwixt.strategy.DefaultObjectStringConverter
public class DefaultObjectStringConverter
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).
Field Summary | |
---|---|
private java.text.SimpleDateFormat |
formatter
Formats Dates to Strings and Strings to Dates |
Fields inherited from class org.apache.commons.betwixt.strategy.ObjectStringConverter |
---|
FLAVOUR_OPTION_NAME |
Constructor Summary | |
---|---|
DefaultObjectStringConverter()
|
Method Summary | |
---|---|
protected void |
handleException(java.lang.Exception e)
Allow subclasses to use a different exception handling strategy. |
private boolean |
isUtilDate(java.lang.Class type)
Is the given type a java.util.Date but not a java.sql.Date? |
java.lang.String |
objectToString(java.lang.Object object,
java.lang.Class type,
java.lang.String flavour,
Context context)
Converts an object to a string representation using ConvertUtils. |
java.lang.Object |
stringToObject(java.lang.String value,
java.lang.Class type,
java.lang.String flavour,
Context context)
Converts an object to a string representation using ConvertUtils. |
Methods inherited from class org.apache.commons.betwixt.strategy.ObjectStringConverter |
---|
objectToString, stringToObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.text.SimpleDateFormat formatter
Constructor Detail |
---|
public DefaultObjectStringConverter()
Method Detail |
---|
public java.lang.String objectToString(java.lang.Object object, java.lang.Class type, java.lang.String flavour, Context context)
EEE MMM dd HH:mm:ss zzz yyyy
will be used.
(This is the same as java.util.Date toString would return.)
objectToString
in class ConvertUtilsObjectStringConverter
object
- the object to be converted, possibly nulltype
- the property class of the object, not nullflavour
- a string allow symantic differences in formatting
to be communicated (ignored)context
- convert against this context not null
public java.lang.Object stringToObject(java.lang.String value, java.lang.Class type, java.lang.String flavour, Context context)
stringToObject
in class ConvertUtilsObjectStringConverter
value
- the String to be converted, not nulltype
- the property class to be returned (if possible), not nullflavour
- a string allow symantic differences
in formatting to be communicated (ignored)context
- not null
protected void handleException(java.lang.Exception e)
org.apache.commons.beanutils.ConversionException
when conversion fails.
e
- the Exception to be handled
org.apache.commons.beanutils.ConversionException
- when conversion failsprivate boolean isUtilDate(java.lang.Class type)
type
- test this class type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |