Top Description Fields Constructors Methods
org.joda.convert

pack-priv final Class ReflectionStringConverter<T>

extends Object
implements TypedStringConverter<T>
Class Inheritance
All Implemented Interfaces
org.joda.convert.TypedStringConverter, org.joda.convert.TypedFromStringConverter, org.joda.convert.FromStringConverter, org.joda.convert.StringConverter, org.joda.convert.ToStringConverter
Type Parameters
<T>
the type of the converter
Imports
java.lang.reflect.InvocationTargetException, .Method

Conversion to and from a string using reflection.

The toString method must meet the following signature:
String anyName() on Class T.

ReflectionStringConverter is abstract, but all known implementations are thread-safe and immutable.

Field Summary

Modifier and TypeField and Description
private final Class<T>
cls

The converted class.

pack-priv final TypedFromStringConverter<T>
fromString

Conversion from a string, package-scoped for testing.

private final Method
toString

Conversion to a string.

Constructor Summary

AccessConstructor and Description
pack-priv
ReflectionStringConverter(Class<T>
the class this converts for, null creates a from-string converter
cls
,
Method
the toString method, not null
toString
,
TypedFromStringConverter<T>
the fromString converter, not null
fromString
)

Creates an instance using two methods.

Method Summary

Modifier and TypeMethod and Description
public T
convertFromString(Class<? extends T>
the class to convert to, not null
cls
,
String
the string to convert, not null
str
)

Implements org.joda.convert.FromStringConverter.convertFromString.

Converts the specified object from a String.
public String
convertToString(T
the object to convert, not null
object
)

Implements org.joda.convert.ToStringConverter.convertToString.

Converts the specified object to a String.
public Class<?>
getEffectiveType()

Implements org.joda.convert.TypedStringConverter.getEffectiveType.

Gets the effective type that the converter works on.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

clsback to summary
private final Class<T> cls

The converted class.

fromStringback to summary
pack-priv final TypedFromStringConverter<T> fromString

Conversion from a string, package-scoped for testing.

toStringback to summary
private final Method toString

Conversion to a string.

Constructor Detail

ReflectionStringConverterback to summary
pack-priv ReflectionStringConverter(Class<T> cls, Method toString, TypedFromStringConverter<T> fromString)

Creates an instance using two methods.

Parameters
cls:Class<T>

the class this converts for, null creates a from-string converter

toString:Method

the toString method, not null

fromString:TypedFromStringConverter<T>

the fromString converter, not null

Exceptions
RuntimeException:
(or subclass) if the method signatures are invalid

Method Detail

convertFromStringback to summary
public T convertFromString(Class<? extends T> cls, String str)

Implements org.joda.convert.FromStringConverter.convertFromString.

Doc from org.joda.convert.FromStringConverter.convertFromString.

Converts the specified object from a String.

Parameters
cls:Class<? extends T>

the class to convert to, not null

str:String

the string to convert, not null

Returns:T

the converted object, may be null but generally not

Annotations
@Override
convertToStringback to summary
public String convertToString(T object)

Implements org.joda.convert.ToStringConverter.convertToString.

Doc from org.joda.convert.ToStringConverter.convertToString.

Converts the specified object to a String.

Parameters
object:T

the object to convert, not null

Returns:String

the converted string, may be null but generally not

Annotations
@Override
getEffectiveTypeback to summary
public Class<?> getEffectiveType()

Implements org.joda.convert.TypedStringConverter.getEffectiveType.

Doc from org.joda.convert.TypedStringConverter.getEffectiveType.

Gets the effective type that the converter works on.

For example, if a class declares the FromString and ToString then the effective type of the converter is that class. If a subclass is queried for a converter, then the effective type is that of the superclass.

Returns:Class<?>

the effective type

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override