|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.convert.ConversionRegistry
public class ConversionRegistry
ConversionRegistry manages the Conversion
and
ConversionFactory
objects.
This class allows conversions to be added, removed and looked up. This implementation is fully synchronized.
Converter converter = new Converter(); converter.getRegistry().addDefaultConversions(); converter.getRegistry().addConversion(new MyNewConversion());
Field Summary | |
---|---|
protected Map |
iConversions
Map of from class to conversion |
protected ConversionFactory[] |
iFactories
Array of conversion factories |
protected Object |
iFactoryLock
Object to synchronize on for factories |
Constructor Summary | |
---|---|
protected |
ConversionRegistry()
Restricted constructor, use Converter. |
Method Summary | |
---|---|
void |
addConversion(Conversion conv)
Adds a Conversion to the map of known conversions. |
void |
addConversionFactory(ConversionFactory factory)
Adds a ConversionFactory to the set of known factories. |
void |
addDefaultConversions()
Add the default set of conversions to the registry. |
Conversion |
getConversion(Object value,
Class fromType,
Class toType)
Gets the conversion object that best matches the from and to types. |
String |
toString()
Returns a string describing this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Map iConversions
protected ConversionFactory[] iFactories
protected final Object iFactoryLock
Constructor Detail |
---|
protected ConversionRegistry()
Method Detail |
---|
public void addDefaultConversions()
public void addConversion(Conversion conv)
conv
- the conversion to addpublic void addConversionFactory(ConversionFactory factory)
equals()
is replaced.
factory
- the factory to addpublic Conversion getConversion(Object value, Class fromType, Class toType)
The lookup first examines the known conversions. If none is found, the
factories are used to search for and create a conversion. If no suitable
factory is found then null
is returned.
value
- the value that will be converted, read only and not to be storedfromType
- the type to convert fromtoType
- the type to convert to
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |