i just finished a checkin of new conversion code. API is quite a bit different, so please examine it carefully.


i spent all day today working on this, so please ask questions before tweaking anything. i'm pretty sure i got this right.

major changes:

- folded localization into a single converter hierarchy

- implemented converters for all primitive types plus Date and String

- introduced ITypeConverter interface for conversions TO some implicit type. this is mainly of
interest internally, since the IConverter interface is more general and useful. but use of type
converters directly is supported and some mucking with ITypeConverters may be necessary
to configure format/parse patterns for locales for your application.


- refactored and simplified Component and TypeValidator to use the new conversion code
this should all be automatic goodness!


pseudo code example of converter API (again, if you're using TypeValidator, you may not even
need to know this):


IConverterFactory f = new ConverterFactory();
IConverter c = f.newConverter();

String s = c.convert(new Integer(5), String.class);
Integer i = c.convert("5", Integer.class);

c.setLocale(Locale.DUTCH);
String s = (String)c.convert(new Date(), String.class);
Date d = (Date)c.convert("10-okt-2002", Date.class);

individual conversions can be registered on the Converter class by the factory,
which is something most people won't generally need to do since
by default conversions are made available for all Java language primitive types
and their enclosing first class objects. also conversions to and from Date and
String are supported. all these conversions will respect Locale if you set it
on the converter and each converter's format can be set if you don't like the
default format for the locale.


conversions to String are somewhat more complex internally and involve registering
string formatting converters (which still implement the same ITypeConverter
interface) on the StringConverter object. this is really quite elegant and allows
for any arbitrary formatting when converting objects to strings. currently locale
formatting for Date and Number types is supported.




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to