|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ezmorph.MorpherRegistry
public class MorpherRegistry
Convenient class that manages Morphers.
A MorpherRehistry manages a group of Morphers. A Morpher will always be
associated with a target class, it is possible to have several Morphers
registered for a target class, if this is the case, the first Morpher will be
used when performing a conversion and no specific Morpher is selected in
advance.
MorphUtils
may be used to register standard Morphers for primitive
types and primitive wrappers, as well as arrays of those types.
Constructor Summary | |
---|---|
MorpherRegistry()
|
Method Summary | |
---|---|
void |
clear()
Deregisters all morphers. |
void |
clear(Class type)
Deregister all Morphers of a type. |
void |
deregisterMorpher(Morpher morpher)
Deregister the specified Morpher. The registry will remove the target Class from the morphers
Map if it has no other registered morphers. |
Morpher |
getMorpherFor(Class clazz)
Returns a morpher for clazz .If several morphers are found for that class, it returns the first. |
Morpher[] |
getMorphersFor(Class clazz)
Returns all morphers for clazz .If no Morphers are found it will return an array containing the IdentityObjectMorpher. |
Object |
morph(Class target,
Object value)
Morphs and object to the specified target class. This method uses reflection to invoke primitive Morphers and Morphers that do not implement ObjectMorpher. |
void |
registerMorpher(Morpher morpher)
Register a Morpher for a target Class .The target class is the class this Morpher morphs to. |
void |
registerMorpher(Morpher morpher,
boolean override)
Register a Morpher for a target Class .The target class is the class this Morpher morphs to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MorpherRegistry()
Method Detail |
---|
public void clear()
public void clear(Class type)
class
- the target type the Morphers morph topublic void deregisterMorpher(Morpher morpher)
Class
from the morphers
Map if it has no other registered morphers.
morpher
- the target Morpher to removepublic Morpher getMorpherFor(Class clazz)
clazz
.
clazz
- the target class for which a Morpher may be associatedpublic Morpher[] getMorphersFor(Class clazz)
clazz
.
clazz
- the target class for which a Morpher or Morphers may be
associatedpublic Object morph(Class target, Object value)
target
- the target class to morph tovalue
- the value to morph
MorphException
- if an error occurs during the conversionpublic void registerMorpher(Morpher morpher)
Class
.
morpher
- a Morpher to register. The method morphsTo()
is used to associate the Morpher to a target Classpublic void registerMorpher(Morpher morpher, boolean override)
Class
.
morpher
- a Morpher to register. The method morphsTo()
is used to associate the Morpher to a target Classoverride
- if registering teh Morpher should override all previously
registered morphers for the target type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |