public int compareTo(Object o) { final String pattern = ((StringComparable)o).toString(); if(m_text.equals(pattern)){//Code-point equals return 0; } final int savedStrength = m_collator.getStrength(); int comp = 0; // Is there difference more significant than case-order? if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){ comp = m_collator.compare(m_text, pattern ); }else{// more than SECONDARY m_collator.setStrength(Collator.SECONDARY); comp = m_collator.compare(m_text, pattern ); m_collator.setStrength(savedStrength); } if(comp != 0){//Difference more significant than case-order return comp ; } // No difference more significant than case-order. // Find case difference comp = getCaseDiff(m_text, pattern); if(comp != 0){ return comp; }else{// No case differences. Less significant difference could exist return m_collator.compare(m_text, pattern ); } }
final String subTextUp = subText.toUpperCase(locale); final String subPattUp = subPatt.toUpperCase(locale); if(m_collator.compare(subTextUp, subPattUp) != 0){ // not case diffference continue; if(m_collator.compare(subText, subTextUp) == 0){ diff[0] = UPPER_CASE; }else if(m_collator.compare(subText, subText.toLowerCase(locale)) == 0){ diff[0] = LOWER_CASE; if(m_collator.compare(subPatt, subPattUp) == 0){ diff[1] = UPPER_CASE; }else if(m_collator.compare(subPatt, subPatt.toLowerCase(locale)) == 0){ diff[1] = LOWER_CASE;
/** * Compare two strings for equality or ordering under the rules of this collation * @param o1 the first string * @param o2 the second string * @return -1, 0, or +1 according to the relative ordering of the strings */ @Override public int compareStrings(CharSequence o1, CharSequence o2) { return uca.compare(o1, o2); }
/** * Ask whether two strings are considered equal under this collation * @param s1 the first string * @param s2 the second string * @return true if the strings are considered equal */ @Override public boolean comparesEqual(CharSequence s1, CharSequence s2) { return uca.compare(s1, s2) == 0; }
/** * Compare two strings * * @param o1 the first string * @param o2 the second string * @return 0 if the strings are considered equal, a negative integer if the first string is less than the second, * a positive integer if the first string is greater than the second */ public int compareStrings(String o1, String o2) { return collator.compare(o1, o2); }
/** * Ask whether two strings are considered equal under this collation * @param s1 the first string * @param s2 the second string * @return true if the strings are considered equal */ @Override public boolean comparesEqual(CharSequence s1, CharSequence s2) { return uca.compare(s1, s2) == 0; }
/** * Compare two strings * * @param o1 the first string * @param o2 the second string * @return 0 if the strings are considered equal, a negative integer if the first string is less than the second, * a positive integer if the first string is greater than the second */ public int compareStrings(String o1, String o2) { return collator.compare(o1, o2); }
/** * Compare two strings for equality or ordering under the rules of this collation * @param o1 the first string * @param o2 the second string * @return -1, 0, or +1 according to the relative ordering of the strings */ @Override public int compareStrings(CharSequence o1, CharSequence o2) { return uca.compare(o1, o2); }
/** * Test whether one string is equal to another, according to the rules * of the XPath compare() function. The result is true if and only if the * compare() method returns zero: but the implementation may be more efficient * than calling compare and testing the result for zero * * @param s1 the first string * @param s2 the second string * @return true iff s1 equals s2 */ public boolean comparesEqual(String s1, String s2) { return collator.compare(s1, s2) == 0; }
/** * Test whether one string is equal to another, according to the rules * of the XPath compare() function. The result is true if and only if the * compare() method returns zero: but the implementation may be more efficient * than calling compare and testing the result for zero * * @param s1 the first string * @param s2 the second string * @return true iff s1 equals s2 */ public boolean comparesEqual(String s1, String s2) { return collator.compare(s1, s2) == 0; }
public int compare(String s1, String s2) { return collator.compare(s1, s2); }
String rule = "<a,A<b,B<c,C<[...]<'1'<'2'<'3'<'4'[...]"; RuleBasedCollator collator = new RuleBasedCollator(rule); return collator.compare(val1,val2);
public int compareTo(Object o) { final String pattern = ((StringComparable)o).toString(); if(m_text.equals(pattern)){//Code-point equals return 0; } final int savedStrength = m_collator.getStrength(); int comp = 0; // Is there difference more significant than case-order? if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){ comp = m_collator.compare(m_text, pattern ); }else{// more than SECONDARY m_collator.setStrength(Collator.SECONDARY); comp = m_collator.compare(m_text, pattern ); m_collator.setStrength(savedStrength); } if(comp != 0){//Difference more significant than case-order return comp ; } // No difference more significant than case-order. // Find case difference comp = getCaseDiff(m_text, pattern); if(comp != 0){ return comp; }else{// No case differences. Less significant difference could exist return m_collator.compare(m_text, pattern ); } }
public int compareTo(Object o) { final String pattern = ((StringComparable)o).toString(); if(m_text.equals(pattern)){//Code-point equals return 0; } final int savedStrength = m_collator.getStrength(); int comp = 0; // Is there difference more significant than case-order? if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){ comp = m_collator.compare(m_text, pattern ); }else{// more than SECONDARY m_collator.setStrength(Collator.SECONDARY); comp = m_collator.compare(m_text, pattern ); m_collator.setStrength(savedStrength); } if(comp != 0){//Difference more significant than case-order return comp ; } // No difference more significant than case-order. // Find case difference comp = getCaseDiff(m_text, pattern); if(comp != 0){ return comp; }else{// No case differences. Less significant difference could exist return m_collator.compare(m_text, pattern ); } }
public int compareTo(Object o) { final String pattern = ((StringComparable)o).toString(); if(m_text.equals(pattern)){//Code-point equals return 0; } final int savedStrength = m_collator.getStrength(); int comp = 0; // Is there difference more significant than case-order? if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){ comp = m_collator.compare(m_text, pattern ); }else{// more than SECONDARY m_collator.setStrength(Collator.SECONDARY); comp = m_collator.compare(m_text, pattern ); m_collator.setStrength(savedStrength); } if(comp != 0){//Difference more significant than case-order return comp ; } // No difference more significant than case-order. // Find case difference comp = getCaseDiff(m_text, pattern); if(comp != 0){ return comp; }else{// No case differences. Less significant difference could exist return m_collator.compare(m_text, pattern ); } }
@Override public int compare(TreeNode o1, TreeNode o2) { if (o1 instanceof TvShowTreeNode && o2 instanceof TvShowTreeNode) { TvShowTreeNode node1 = (TvShowTreeNode) o1; TvShow tvShow1 = (TvShow) node1.getUserObject(); TvShowTreeNode node2 = (TvShowTreeNode) o2; TvShow tvShow2 = (TvShow) node2.getUserObject(); if (stringCollator != null) { return stringCollator.compare(tvShow1.getTitleSortable().toLowerCase(Locale.ROOT), tvShow2.getTitleSortable().toLowerCase(Locale.ROOT)); } return tvShow1.getTitleSortable().compareToIgnoreCase(tvShow2.getTitleSortable()); } return o1.toString().compareToIgnoreCase(o2.toString()); } };
public int compare(Object o1, Object o2) { try{ RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); return r_collator.compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName()); }catch(ParseException e){ return Collator.getInstance().compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName()); } } };
public int compare(Object o1, Object o2) { try{ RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); return r_collator.compare(((EnrollmentRecord)o1).getUser().getDisplayId(),((EnrollmentRecord)o2).getUser().getDisplayId()); }catch(ParseException e){ return Collator.getInstance().compare(((EnrollmentRecord)o1).getUser().getDisplayId(),((EnrollmentRecord)o2).getUser().getDisplayId()); } } };
public int compare(Object o1, Object o2) { try{ RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); return r_collator.compare(((EnrollmentRecord)o1).getUser().getDisplayId(),((EnrollmentRecord)o2).getUser().getDisplayId()); }catch(ParseException e){ return Collator.getInstance().compare(((EnrollmentRecord)o1).getUser().getDisplayId(),((EnrollmentRecord)o2).getUser().getDisplayId()); } } };
public int compare(Object o1, Object o2) { try{ RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); return r_collator.compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName()); }catch(ParseException e){ return Collator.getInstance().compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName()); } } };