Top Description Fields Constructors Methods
org.joda.convert

pack-priv final Class MethodFromStringConverter<T>

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

Conversion from a string using a static method.

The fromString method must meet the following signature:
static T anyName(String) on any class.

MethodFromStringConverter is thread-safe and immutable.

Field Summary

Modifier and TypeField and Description
private final Class<?>
effectiveType

Effective type.

private final Method
fromString

Conversion from a string.

Constructor Summary

AccessConstructor and Description
pack-priv
MethodFromStringConverter(Class<T>
the class this converts for, not null
cls
,
Method
the fromString method, not null
fromString
,
Class<?> effectiveType)

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 Class<?>
getEffectiveType()

Implements org.joda.convert.TypedFromStringConverter.getEffectiveType.

Gets the effective type that the converter works on.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

effectiveTypeback to summary
private final Class<?> effectiveType

Effective type.

fromStringback to summary
private final Method fromString

Conversion from a string.

Constructor Detail

MethodFromStringConverterback to summary
pack-priv MethodFromStringConverter(Class<T> cls, Method fromString, Class<?> effectiveType)

Creates an instance using two methods.

Parameters
cls:Class<T>

the class this converts for, not null

fromString:Method

the fromString method, 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
getEffectiveTypeback to summary
public Class<?> getEffectiveType()

Implements org.joda.convert.TypedFromStringConverter.getEffectiveType.

Doc from org.joda.convert.TypedFromStringConverter.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