Project: Eclipse_Platform_UI
Bug 168226 [Viewers] default ViewerComparator is case sensitive (doesn't match spec)
Reported: 2006-12-15 11:12:23 | Status: verified fixed

I'm implementing some kind of viewer and found out that default comparator is sorting case SENSITIVE while JavaDoc says it's case INSENSITIVE: JavaDoc of method int compare(viewer, object, object) form ViewerComparator: * The default implementation of this method is based on * comparing the elements' categories as computed by the <code> category </code> * framework method. Elements within the same category are further * subjected to a case insensitive compare of their label strings, either * as computed by the content viewer's label provider, or their * <code>toString</code> values in other cases. Subclasses may override.</p> but when you'll go deeply to get the source code of the default comparator, which you'll find in Policy.java, there will be: private static Comparator getDefaultComparator(){ return new Comparator(){ /** * Compares string s1 to string s2. * * @param s1 string 1 * @param s2 string 2 * @return Returns an integer value. Value is less than zero if source is * less than target, value is zero if source and target are equal, * value is greater than zero if source is greater than target. * @exception ClassCastException the arguments cannot be cast to Strings. */ public int compare(Object s1, Object s2) { return ((String)s1).compareTo((String)s2); } }; }

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java