commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernard, Shawn" <Shawn.Bern...@turner.com>
Subject RE: [BeanUtils] case insensitive BeanComparator?
Date Wed, 07 Sep 2005 19:45:11 GMT
Thanks!  That worked like a charm.

-Shawn

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Wednesday, September 07, 2005 3:47 PM
To: Jakarta Commons Users List
Subject: Re: [BeanUtils] case insensitive BeanComparator?


...or if you don't want to declare a new class....

 Transformer transformer = new Transformer() {
       public Object transform(Object input) {
            return ((String)input).toLowerCase();
       }
 };
 Comparator comparator = new TransformingComparator(transformer);
 Collections.sort(foobies, new BeanComparator("billingAddress.lastName",

comparator));

Niall

----- Original Message ----- 
From: "Niall Pemberton" <niall.pemberton@blueyonder.co.uk>
Sent: Wednesday, September 07, 2005 8:30 PM


> You could create an org.apache.commons.collections.Transformer ....
>
> public class LowerCaseTransformer implements Transformer {
>      public Object transform(Object input) {
>           return ((String)input).toLowerCase();
>      }
> }
>
> Comparator comparator = new TransformingComparator(new
> LowerCaseTransformer());
> Collections.sort(foobies, new BeanComparator("billingAddress.lastName",
> comparator));
>
> Niall
>
> ----- Original Message ----- 
> From: "Bernard, Shawn" <Shawn.Bernard@turner.com>
> Sent: Wednesday, September 07, 2005 7:15 PM
>
>
> I'm using a BeanComparator in a Collections.sort():
>
>    Collections.sort(foobies, new
BeanComparator("billingAddress.lastName"));
>
> I was wondering if there was a way to make the sort case insensitive
> (without creating my own custom comparator).
>
> Thanks,
>
> Shawn
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message