commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Almiray <aalmi...@yahoo.com>
Subject Re: [convert] Project restart ?
Date Tue, 01 Aug 2006 14:48:51 GMT

 --- Henri Yandell <flamefew@gmail.com> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message