|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.validation.DefaultTypeConverterFactory
public class DefaultTypeConverterFactory
Default TypeConverterFactory implementation that simply creates an instance level map of all the TypeConverters included in the Stripes distribution, and their applicable classes. Can handle all the primitive and wrapper types as well as the rich types for which type converters exist.
Constructor Summary | |
---|---|
DefaultTypeConverterFactory()
|
Method Summary | |
---|---|
void |
add(Class<?> targetType,
Class<? extends TypeConverter<?>> converterClass)
Adds a TypeConverter to the set of registered TypeConverters, overriding an existing converter if one was registered for the type. |
protected Class<? extends TypeConverter<?>> |
cacheTypeConverterClass(Class<?> clazz,
Class<? extends TypeConverter<?>> converterClass)
Add converter class converterClass for converting objects of type clazz . |
protected void |
clearCache()
Clear the instance cache. |
protected Class<? extends TypeConverter<?>> |
findTypeConverterClass(Class<?> targetClass)
Search for a type converter class that best matches the requested class. |
protected Configuration |
getConfiguration()
Provides subclasses with access to the configuration provided at initialization. |
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. |
protected Map<Class<?>,Class<? extends TypeConverter<?>>> |
getTypeConverters()
Gets the (rather confusing) Map of TypeConverter objects. |
void |
init(Configuration configuration)
Places all the known convertible types and type converters into an instance level Map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultTypeConverterFactory()
Method Detail |
---|
public void init(Configuration configuration)
init
in interface ConfigurableComponent
configuration
- the Configuration object being used by Stripesprotected Configuration getConfiguration()
protected Map<Class<?>,Class<? extends TypeConverter<?>>> getTypeConverters()
public void add(Class<?> targetType, Class<? extends TypeConverter<?>> converterClass)
add
in interface TypeConverterFactory
targetType
- the type for which the converter will handle conversionsconverterClass
- the implementation class that will handle the conversionspublic TypeConverter getTypeConverter(Class forType, Locale locale) throws Exception
getTypeConverter
in interface TypeConverterFactory
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 instantiatedprotected Class<? extends TypeConverter<?>> findTypeConverterClass(Class<?> targetClass)
targetClass
- the class of the object that needs to be converted
protected Class<? extends TypeConverter<?>> cacheTypeConverterClass(Class<?> clazz, Class<? extends TypeConverter<?>> converterClass)
converterClass
for converting objects of type clazz
.
clazz
- the type of object being convertedconverterClass
- the class of the converter
targetType
parameterprotected void clearCache()
add(Class, Class)
.
public TypeConverter getInstance(Class<? extends TypeConverter> clazz, Locale locale) throws Exception
getInstance
in interface TypeConverterFactory
clazz
- the TypeConverter type that is desiredlocale
- the locale of the Strings to be converted with the returned converter
Exception
- if there is a problem instantiating the TypeConverter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |