You can't subclass String because it's final. But you can create a String
wrapper class that implements Comparable and perform your case insensitive
compare there. Then, in a decorator, return an instance of this wrapper
class.
Don't know if this is the best way - but it is functional.
example:
/* String wrapper class to implement case insensitive sorting */
public class CaseInsensitiveString implements Serializable, Comparable {
private String s;
public CaseInsensitiveString(String s) {
this.s = s;
}
public String toString() {
return s.toString();
}
public int compareTo(Object o) {
// ignore case on compare
return this.s.compareToIgnoreCase(((CaseInsensitiveString) o).s);
}
}
/* decorator */
public class MyDecorator extends TableDecorator {
public CaseInsensitiveString getMyString() {
// build a case insensitive string object to wrap the string
representation
// of your object or object property as needed
return new CaseInsensitiveString(((MyObject)
getObject()).getSomeProperty());
}
}
HTH
-Jay
> -----Original Message-----
> From: Ryan Bell [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 01, 2003 5:20 PM
> To: [EMAIL PROTECTED]
> Subject: [displaytag-user] easy way to sort simple String columns
> case-insensitively?
>
>
> I've looked through the information at
> http://edhill.its.uiowa.edu/display/ and saw no easy way to
> get a sort of a column of strings case-insensitive in the
> display tag. I'm not talking about the initial sorting but
> the sort once a column that is sortable is clicked. Is there
> an easier way to do this than subclassing String and
> overriding the compareTo method?
>
> Thanks,
> Ryan
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user