|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TypeConverterFactory
Provides access to a set of TypeConverters for converting Strings to various types. Implementations may use any mechanism desired to map a type to a TypeConverter, and may optionally choose to cache TypeConverter instances. The behaviour of the type conversion lookups in Stripes can be altered either by directly implementing this interface, or by subclassing DefaultTypeConverterFactory.
Method Summary | |
---|---|
void |
add(Class<?> targetType,
Class<? extends TypeConverter<?>> converterClass)
Adds a type converter to the set of registered type converters, overriding an existing converter if one was already registered for the type. |
TypeConverter |
getInstance(Class<? extends TypeConverter> clazz,
Locale locale)
Gets an instance of the TypeConverter class specified. |
TypeConverter |
getTypeConverter(Class forType,
Locale locale)
Gets the applicable type converter for the class passed in. |
Methods inherited from interface net.sourceforge.stripes.config.ConfigurableComponent |
---|
init |
Method Detail |
---|
TypeConverter getTypeConverter(Class forType, Locale locale) throws Exception
forType
- the type/Class that is the target type of the conversion. It is assumed that
the input type is String, so to convert a String to a Date object you would supply
java.util.Date.class.locale
- the locale of the Strings to be converted with the returned converter
Exception
- if the TypeConverter cannot be instantiatedTypeConverter getInstance(Class<? extends TypeConverter> clazz, Locale locale) throws Exception
clazz
- the Class object representing the desired TypeConverterlocale
- the locale of the Strings to be converted with the returned converter
Exception
- if the TypeConverter cannot be instantiatedvoid add(Class<?> targetType, Class<? extends TypeConverter<?>> converterClass)
UnsupportedOperationException
.
targetType
- the type for which the converter will handle conversionsconverterClass
- the implementation class that will handle the conversions
UnsupportedOperationException
- if the implementation does not support adding type
converters at runtime
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |