Quaqua 5.4.1 2009-07-14

ch.randelshofer.quaqua.filechooser
Class OSXCollator

java.lang.Object
  extended by java.text.Collator
      extended by 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:

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 84 2009-06-11 14:55:05Z wrandelshofer $
Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class java.text.Collator
CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION, IDENTICAL, NO_DECOMPOSITION, PRIMARY, SECONDARY, TERTIARY
 
Constructor Summary
OSXCollator()
          Creates a new instance.
OSXCollator(java.util.Locale locale)
           
 
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
 

Constructor Detail

OSXCollator

public OSXCollator()
Creates a new instance.


OSXCollator

public OSXCollator(java.util.Locale locale)
Method Detail

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

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.