net.sf.ezmorph
Class MorpherRegistry

java.lang.Object
  extended by net.sf.ezmorph.MorpherRegistry

public class MorpherRegistry
extends java.lang.Object

Convenient class that manages Morphers.

Author:
Andres Almiray

Constructor Summary
MorpherRegistry()
           
 
Method Summary
 void clear()
          Deregisters all morphers.
 void deregisterMorpher(Morpher morpher)
          Deregister the specified Morpher.
 Morpher getMorpherFor(java.lang.Class clazz)
          Returns a morpher for clazz.
 Morpher[] getMorphersFor(java.lang.Class clazz)
          Returns all morphers for clazz.
 java.lang.Object morph(java.lang.Class target, java.lang.Object value)
          Morphs and object to the specified target class.
 void registerMorpher(Morpher morpher)
          Register a Morpher for a target Class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MorpherRegistry

public MorpherRegistry()
Method Detail

clear

public void clear()
Deregisters all morphers.


deregisterMorpher

public 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.

Parameters:
morpher -

getMorpherFor

public Morpher getMorpherFor(java.lang.Class clazz)
Returns a morpher for clazz.
If several morphers are found for that class, it returns the first. If no Morpher is found it will return the IdentityObjectMorpher.


getMorphersFor

public Morpher[] getMorphersFor(java.lang.Class clazz)
Returns all morphers for clazz.
If no Morphers are found it will return an array containing the IdentityObjectMorpher.


morph

public java.lang.Object morph(java.lang.Class target,
                              java.lang.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.

Parameters:
target -
value -
Returns:

registerMorpher

public void registerMorpher(Morpher morpher)
Register a Morpher for a target Class.
The target class is the class this Morpher morphs to. If there are another morphers registered to that class, it will be appended to a List.

Parameters:
morpher -


Copyright © 2006 null. All Rights Reserved.