--- Henri Yandell <[EMAIL PROTECTED]> escribió:

> What are your thoughts on the current API in
> commons-convert? It's
> much simpler to start with that and start improving
> that to get a new
> codebase + software grant added in.  Is it much the
> same, or is there
> a critical design difference?
> 

Before refactoring the code I looked at the current
convert repository and used the idea of a generic
array Conversion. Now in order to assert that certain
Converter can process a Class and provide information
about which class it converts to, I added two methods
to the Convert interface.

I have the following:

public interface Convert{
   Class convertsTo();
   boolean supports( Class clazz );
}

public interface ObjectConvert extends Convert{
   Object convert( Object value );
}

Notice that Convert has no convert() method declared,
it is intended for primitive converters to define an
appropriate method like:

public clas IntConverter implements Convert{
   int convert( Object value ){
      ...
   }
}

and then invoke it with reflection or direct type
manipulation inside the API.

I molded the Converter interface following example
code from Spring instead of doing it by constructor as
in the convert repository. This allows for any
converter to process many source classes and produce
one target class (a feature also requested on
beanutils) but imposes another degree of complexity
when locating an appropriate Converter, example:

StringConverter -> from any Class to String using
String.valueOf()
TimeZonetoStringConverter -> from TimeZone to String
using getId()


-------------------------------------------
Ing. Andres Almiray Jaramillo
http://jroller.com/page/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and 
those who don't.
To understand recursion, we must first understand recursion.


        
        
                
___________________________________________________________ 
Do You Yahoo!? 
La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. 
http://net.yahoo.com.mx 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to