Package org.apache.ofbiz.base.conversion
Class Converters
- java.lang.Object
-
- org.apache.ofbiz.base.conversion.Converters
-
public class Converters extends java.lang.Object
AConverter
factory and repository.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Converters.PassThruConverter<S,T>
Pass thru converter used when the source and target java object types are the same.protected static class
Converters.PassThruConverterCreator
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.concurrent.ConcurrentHashMap<java.lang.String,Converter<?,?>>
converterMap
protected static java.lang.String
DELIMITER
protected static java.lang.String
module
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S,T>
Converter<S,T>getConverter(java.lang.Class<S> sourceClass, java.lang.Class<T> targetClass)
Returns an appropriateConverter
instance forsourceClass
andtargetClass
.static void
loadContainedConverters(java.lang.Class<?> containerClass)
Load all classes that implementConverter
and are contained incontainerClass
.static <S,T>
voidregisterConverter(Converter<S,T> converter)
Registers aConverter
instance to be used by thegetConverter(Class, Class)
method.static <S,T>
voidregisterConverter(Converter<S,T> converter, java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
static <S,T>
voidregisterCreator(ConverterCreator creator)
Registers aConverterCreater
instance to be used by thegetConverter(Class, Class)
method, when a converter can't be found.
-
-
-
Field Detail
-
module
protected static final java.lang.String module
-
DELIMITER
protected static final java.lang.String DELIMITER
- See Also:
- Constant Field Values
-
converterMap
protected static final java.util.concurrent.ConcurrentHashMap<java.lang.String,Converter<?,?>> converterMap
-
-
Method Detail
-
getConverter
public static <S,T> Converter<S,T> getConverter(java.lang.Class<S> sourceClass, java.lang.Class<T> targetClass) throws java.lang.ClassNotFoundException
Returns an appropriateConverter
instance forsourceClass
andtargetClass
. If no matchingConverter
is found, the method throwsClassNotFoundException
.This method is intended to be used when the source or target
Object
types are unknown at compile time. If the source and targetObject
types are known at compile time, then one of the "ready made" converters should be used.- Parameters:
sourceClass
- The object class to convert fromtargetClass
- The object class to convert to- Returns:
- A matching
Converter
instance - Throws:
java.lang.ClassNotFoundException
-
loadContainedConverters
public static void loadContainedConverters(java.lang.Class<?> containerClass)
Load all classes that implementConverter
and are contained incontainerClass
.- Parameters:
containerClass
-
-
registerCreator
public static <S,T> void registerCreator(ConverterCreator creator)
Registers aConverterCreater
instance to be used by thegetConverter(Class, Class)
method, when a converter can't be found.- Type Parameters:
S
- The source object typeT
- The target object type- Parameters:
creator
- TheConverterCreater
instance to register
-
registerConverter
public static <S,T> void registerConverter(Converter<S,T> converter)
Registers aConverter
instance to be used by thegetConverter(Class, Class)
method.- Type Parameters:
S
- The source object typeT
- The target object type- Parameters:
converter
- TheConverter
instance to register
-
registerConverter
public static <S,T> void registerConverter(Converter<S,T> converter, java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
-
-