1 package net.sf.saxon.sort; 2 import java.text.Collator ; 3 import java.util.Comparator ; 4 5 11 12 public class UppercaseFirstComparer implements Comparator , java.io.Serializable { 13 14 private Collator baseCollator; 15 16 public UppercaseFirstComparer(Collator base) { 17 baseCollator = base; 18 baseCollator.setStrength(Collator.SECONDARY); 19 } 20 21 27 28 public int compare(Object a, Object b) { 29 int diff = baseCollator.compare(a, b); 30 if (diff != 0) { 31 return diff; 32 } 33 34 CharSequence a1 = (CharSequence )a; 35 CharSequence b1 = (CharSequence )b; 36 for (int i=0; i<a1.length(); i++) { 37 if (a1.charAt(i) != b1.charAt(i)) { 38 return (Character.isUpperCase(a1.charAt(i)) ? -1 : +1); 39 } 40 } 41 return 0; 42 43 44 59 } 60 61 } 62 63 | Popular Tags |