Tuesday, January 20, 2004, 6:05:20 PM, you wrote:
>>Again, such values exist in our (mostly internal) configuration files.
SY> OK, I see your use-cases.
>>Besides, I'd like to see the constructor-valueOf-asList-toArray stuff
>>cleaned up a bit by a common interface.
SY> I don't share that desire. I think it's neat that each class knows (and
SY> exposes) what conversions it can and can't do. It's nice encapsulation.
SY> If you want a central converter, suit yourself ;)
Just firing up random thoughts here (drilled down into my head a few
inches), but suppose you could use your private TypeConverter, then
you could
1) Again, provide a converter for configurations from String,
ConfigurationEntry, or whatever, to the user's desired type. Say
foo.properties:
component.factory=some.package.with.Factory
Class factoryClass =
(Class)getConfiguration().getConvertedEntry("component.factory", Class.class);
or even, for the more adventurous
/* String - Class(forName) - Object(newInstance) */
Factory f =
(Factory)getConfiguration.getConvertedEntry("component.factory", Object.class);
2) An object renderer, to convert types to a Strings (if everybody
would just implement toString...), maybe with locale support (if you want
to).
Even if you want to keep the conversions in the class, it would, IMHO,
make a nice helper for them.
Ron
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]