public class ObjectStringConverter extends Object implements Serializable
Strategy class for string <-> object conversions. Implementations of this interface are used by Betwixt to perform string <-> object conversions. This performs only the most basic conversions. Most applications will use a subclass.
It is strongly recommended that (in order to support round tripping)
that objectToString
and stringToObject
are inverse functions.
In other words, given the same flavour, context and type the applying
objectToString to the result of stringToObject should be equal to the
original input.
Modifier and Type | Field and Description |
---|---|
static String |
FLAVOUR_OPTION_NAME
Standard name for option giving flavour
|
Constructor and Description |
---|
ObjectStringConverter() |
Modifier and Type | Method and Description |
---|---|
String |
objectToString(Object object,
Class type,
Context context)
Converts an object to a string representation.
|
String |
objectToString(Object object,
Class type,
String flavour,
Context context)
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 Context.getOptions() |
Object |
stringToObject(String value,
Class type,
Context context)
Converts a string representation to an object.
|
Object |
stringToObject(String value,
Class type,
String flavour,
Context context)
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 Context.getOptions() |
public static final String FLAVOUR_OPTION_NAME
public String objectToString(Object object, Class type, String flavour, Context context)
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 Context.getOptions()
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 communicatedcontext
- the context, not nullpublic Object stringToObject(String value, Class type, String flavour, Context context)
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 Context.getOptions()
value
- the String to be convertedtype
- the property class to be returned (if possible), not nullflavour
- a string allow symantic differences in formatting to be communicatedcontext
- the context, not nullpublic String objectToString(Object object, Class type, Context context)
object
- the object to be converted, possibly nulltype
- the property class of the object, not nullcontext
- the context, not nullpublic Object stringToObject(String value, Class type, Context context)
value
- the String to be convertedtype
- the property class to be returned (if possible), not nullcontext
- the context, not nullCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.