commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [beanutils] GenericComparator -I have a project I'd like to contribute to Jakarta Commons.
Date Sun, 05 Oct 2003 22:21:36 GMT
i've been wanting to factor out the bean query language (so that users can 
plug-in alternative implementations) for ages now. maybe this could 
provide some momentum for this change.

- robert

On Thursday, October 2, 2003, at 09:39 PM, Henri Yandell wrote:

>
> BeanComparator does parts of this too, but doesn't have the EL-style
> language that Wickus has.
>
> Hen
>
> On Thu, 2 Oct 2003, Stephen Colebourne wrote:
>
>> Tagged to the right commons project.
>> You might want to look at how beanutils accesses bean properties - its
>> slightly different to how you do it.
>>
>> Stephen
>>
>> ----- Original Message -----
>> From: "Wickus Martin" <wickus@exinet.co.za>
>>> A while back I wrote a generic comparator for Java objects and called it
>>> GComp. We've been using it internally at the company where I work, but 
>>> I
>> was
>>> wondering if it might not be of value to the commons project.
>>>
>>> Typically Java programmers create a custom Comparator implementation for
>>> every comparison scenario they encounter. GComp on the other hand can
>>> compare objects according to complex criteria based on a simple 
>>> expression
>>> that explains how the objects should be compared. Great time saver and
>>> prevents problem of many small comparator classes bloating the code 
>>> base.
>>>
>>> Usage scenario:
>>>
>>> Lets say we have a class called Customer with methods to access the 
>>> first
>>> name and last name. Lets also say we have a class called Order that 
>>> holds
>> a
>>> reference to an instance of Customer.
>>>
>>> To compare orders according to the customer surname (ascending) we could
>>> create the following comparator:
>>>
>>> new GComp("getLastName");
>>>
>>> To compare a collection of orders according to the customer last name
>>> (ascending) and then first name (descending) for those customers with 
>>> the
>>> same last name we could create the following comparator:
>>>
>>> new
>>>
>> GComp("getCustomer.getLastName@order=asc|getCustomer.getFirstName@order=
>> desc
>>> ");
>>>
>>> To order null values last and ignore case we could create:
>>>
>>> new
>>>
>> GComp("getCustomer.getLastName.toLowerCase@order=asc,nulls=last|getCustomer.
>>> getFirstName.toLowerCase@order=desc,nulls=last");
>>>
>>>
>>> The above code only orders on string objects, but all objects 
>>> implementing
>>> the comparable interface is supported as is primitive types.
>>>
>>> Currently GComp uses commons-logging to output debugging information if
>>> commons logging is found on the classpath.
>>>
>>> I'm happy to donate the code for further study. Let me know.
>>>
>>> Keep well,
>>> Wickus Martin
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
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