On Sun, 28 Sep 2003, Sgarlata Matt wrote:

> From: "Henri Yandell" <[EMAIL PROTECTED]>
>
> > Secondly...I think the Convert system needs improvement. The basic problem
> > is highlighted by:  ConvertUtils.register(Converter, Class).
> > It ought to be:  ConvertUtils.register(Converter, Class from, Class to).
>
> I agree this may be more intuitive and easier to program, but I think the
> current system does the job (see additional comments below).
>
> > I want to register a Converter for Date->String and another for
> > Date->sql.Timestamp.
>
> I believe this is already possible.  The calls would be
> ConvertUtils.register(DateConverter, java.util.Date);
> ConvertUtils.register(DateConverter, java.sql.Date);

So how would I register a Converter to handle sql.Date->Long converting?

I want [hypothetically, please ignore inheritence here]:

sql.Date->sql.Timestamp
util.Date->sql.Timestamp
util.Date->lang.Long

The current register system means I have to write my own registry system
in my converter.

I believe the ConvertUtils registry wants to actually be a multi-registry
[ie registry of registries], which can return either a value when given
two keys, or a registry when given one key.

Beanutils would usually ask for:
ConvertRegistry.get(String.class, <type>) when pushing data in, and
would ask for ConvertRegistry.get(<type>, Object.class) when outputting
data. The Converter in charge of 'Long' to Object is effectively the
default one.

It could also save a little effort by asking for:
ConvertRegistry.getLHS(String.class) and it would get a ConvertSubRegistry
which always assumes the left hand side is a String.

Hen


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

Reply via email to