[REVIEW REQUEST] Pre-built StringConverter Implementations
Jonathan Giles
jonathan.giles at oracle.com
Thu Dec 22 20:32:52 PST 2011
Hi all,
I have updated RT-17956 to now have an updated code drop of the
pre-built StringConverters. In summary, the changes are:
* I've split the NumberStringConverter and DateTimeStringConverter
into three classes each to simplify the API:
o NumberStringConverter continues to exist, and there are two
subclasses:
+ CurrencyStringConverter,
+ PercentageStringConverter
o DateTimeStringConverter continues to exist, and there are two
subclasses:
+ DateStringConverter
+ TimeStringConverter
* I've added constructors to the six classes above to make it possible
to easily set a string converter in a single line (rather than
requiring multiple lines of setters).
* I've simplified the API considerably by removing all getters /
setters to effectively make the converter immutable once it has been
instantiated.
* I've updated the unit tests to cover 100% of the code and 100% of
the branches in 179 unit tests.
Assuming there is no feedback in the next few days I intend to push
these converters to the open source 'rt' folder.
-- Jonathan
On 21/12/2011 3:37 p.m., Jonathan Giles wrote:
> With the introduction of the ComboBox control (and discussion around
> editable Spinner and future controls like the Calendar Picker) we are
> more formally working towards consistently using the StringConverter
> in various places in the controls API, and usages of this class will
> only become more prevalent over time.
>
> One of the goals for JavaFX after shipping JavaFX 2.0 was to fill in
> the gaps in the API. One gap that is now more important than ever is
> to provide a number of pre-built StringConverters, and this is what
> I'm keen to have reviewed today. As part of introducing the ComboBox
> control, I'm wanting to make available a number of these
> implementations. You can find all source code to these implementations
> in the Jira issue for the ComboBox control [1].
>
> All implementations are forked from JSR-273: Design-Time API for
> JavaBeans (JBDT), in particular, the code from the package
> javax.beans.convert [2]. This is the same JSR that Rich recently
> forked for design time APIs that appeared in the repo. There have been
> some changes in the forked code:
>
> * All classes have been renamed from <type>PropertyConverter to
> <type>StringConverter.
> * All classes extend javafx.util.StringConverter rather than
> PropertyConverter.
> * StringConverter, having a generic type, allows for the method
> signatures to be more type-specific, which we now take advantage of.
>
> At a higher level, this API will be a new javafx-ui-converter project
> inside the open source 'rt' folder. With regard to unit tests, it is
> my intention to write unit tests to cover all use cases, to ensure
> validity and consistency. Presently I have 150 unit tests that cover
> 84% of lines and 74% of branches, and this will increase as time permits.
>
> I do have some questions:
>
> * Can people foresee any issues with the more tightly-constrained
> generics? I can't imagine there being an issue, but let me know...
> * What used to be called StringPropertyConverter is now called
> DefaultStringConverter, which is a kind of a shame (with 'Default'
> being a bit of a misnomer). Sure, to be accurate I'd call it
> StringStringConverter, but that ain't any better... :-)
>
> Any feedback would be much appreciated.
>
> [1] http://javafx-jira.kenai.com/browse/RT-17956
> [2]
> http://www.koders.com/info.aspx?c=ProjectInfo&pid=BRCKM22353APEAQBQ3MY5WMRCA
>
> Thanks,
> -- Jonathan
More information about the openjfx-dev
mailing list