ch.randelshofer.quaqua.filechooser
Class OSXCollator
java.lang.Object
java.text.Collator
ch.randelshofer.quaqua.filechooser.OSXCollator
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Comparator<java.lang.Object>
public class OSXCollator
- extends java.text.Collator
The OSXCollator strives to match the collation rules used by the Mac OS X
Finder and of Mac OS X file dialogs.
If we wanted to match the OS X collation rules exactly, we would have to
implement the rules for all languages supported by Mac OS X and Java.
To reduce the amount of work needed for implementing these rules, the
OSXCollator changes the collation rules returned by
java.text.Collator.getInstance() to do the following:
- Space characters are treated as primary collation differences
- Hyphen characters are treated as primary collation differences
- Sequence of digits (characters '0' through '9') is treated as a single
collation object. The current implementation supports sequences of up to
999 characters length.
If java.text.Collator.getInstance() does not return an instance of
java.text.RuleBasedCollator, then the returned collator is used, and only
sequences of digits are changed to match the collation rules of Mac OS X.
- Version:
- $Id: OSXCollator.java 363 2010-11-21 17:41:04Z wrandelshofer $
- Author:
- Werner Randelshofer
Fields inherited from class java.text.Collator |
CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION, IDENTICAL, NO_DECOMPOSITION, PRIMARY, SECONDARY, TERTIARY |
Method Summary |
int |
compare(java.lang.String source,
java.lang.String target)
|
boolean |
equals(java.lang.Object o)
|
java.text.CollationKey |
getCollationKey(java.lang.String source)
|
int |
hashCode()
|
Methods inherited from class java.text.Collator |
clone, compare, equals, getAvailableLocales, getDecomposition, getInstance, getInstance, getStrength, setDecomposition, setStrength |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
OSXCollator
public OSXCollator()
- Creates a new instance.
OSXCollator
public OSXCollator(java.util.Locale locale)
compare
public int compare(java.lang.String source,
java.lang.String target)
- Specified by:
compare
in class java.text.Collator
getCollationKey
public java.text.CollationKey getCollationKey(java.lang.String source)
- Specified by:
getCollationKey
in class java.text.Collator
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interface java.util.Comparator<java.lang.Object>
- Overrides:
equals
in class java.text.Collator
hashCode
public int hashCode()
- Specified by:
hashCode
in class java.text.Collator