dog.util
Class TreeCollator

java.lang.Object
  |
  +--java.text.Collator
        |
        +--dog.util.TreeCollator
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator

public class TreeCollator
extends java.text.Collator

A class for comparing objects in a tree.


Field Summary
protected  java.text.Collator collator
           
protected  boolean descending
           
 
Fields inherited from class java.text.Collator
CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION, IDENTICAL, NO_DECOMPOSITION, PRIMARY, SECONDARY, TERTIARY
 
Constructor Summary
TreeCollator()
          Constructs a TreeCollator for the default locale.
TreeCollator(java.util.Locale locale)
          Constructs a TreeCollator for the specified locale.
 
Method Summary
protected  int applyDescending(int comparison)
          Utility method to return the opposite of a comparison if descending is true.
 int compare(java.lang.Object source, java.lang.Object target)
          Compares the source object to the target object according to the collation rules for this Collator.
 int compare(java.lang.String source, java.lang.String target)
          Compares the source string to the target string according to the collation rules for this Collator.
 boolean equals(java.lang.Object other)
           
 boolean equals(java.lang.String source, java.lang.String target)
          Convenience method for comparing the equality of two strings based on this Collator's collation rules.
 java.text.CollationKey getCollationKey(java.lang.String source)
          Transforms the String into a series of bits that can be compared bitwise to other CollationKeys.
 int getDecomposition()
          Get the decomposition mode of this Collator.
 int getStrength()
          Returns this Collator's strength property.
 int hashCode()
           
 boolean isDescending()
          Indicates whether this collator returns the opposite of any comparison.
protected  java.lang.StringBuffer paramString()
           
 void setDecomposition(int decompositionMode)
          Set the decomposition mode of this Collator.
 void setDescending(boolean descending)
          Sets whether this collator returns the opposite of any comparison.
 void setStrength(int newStrength)
          Sets this Collator's strength property.
 java.lang.String toString()
          Provides a string description of this object.
 
Methods inherited from class java.text.Collator
clone, getAvailableLocales, getInstance, getInstance
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

collator

protected java.text.Collator collator

descending

protected boolean descending
Constructor Detail

TreeCollator

public TreeCollator()
Constructs a TreeCollator for the default locale.

TreeCollator

public TreeCollator(java.util.Locale locale)
Constructs a TreeCollator for the specified locale.
Method Detail

isDescending

public boolean isDescending()
Indicates whether this collator returns the opposite of any comparison.
See Also:
setDescending(boolean)

setDescending

public void setDescending(boolean descending)
Sets whether this collator returns the opposite of any comparison.
Parameters:
descending - true if this collator returns the opposite of any comparison, false otherwise
See Also:
setDescending(boolean)

applyDescending

protected int applyDescending(int comparison)
Utility method to return the opposite of a comparison if descending is true.

compare

public int compare(java.lang.String source,
                   java.lang.String target)
Compares the source string to the target string according to the collation rules for this Collator. Returns an integer less than, equal to or greater than zero depending on whether the source String is less than, equal to or greater than the target string.
Overrides:
compare in class java.text.Collator
Parameters:
source - the source string.
target - the target string.
See Also:
CollationKey

compare

public int compare(java.lang.Object source,
                   java.lang.Object target)
Compares the source object to the target object according to the collation rules for this Collator. Returns an integer less than, equal to or greater than zero depending on whether the source object is less than, equal to or greater than the target object. Objects that can validly be compared by such means include:

getCollationKey

public java.text.CollationKey getCollationKey(java.lang.String source)
Transforms the String into a series of bits that can be compared bitwise to other CollationKeys. CollationKeys provide better performance than Collator.compare when Strings are involved in multiple comparisons.
Overrides:
getCollationKey in class java.text.Collator
Parameters:
source - the string to be transformed into a collation key.
Returns:
the CollationKey for the given String based on this Collator's collation rules. If the source String is null, a null CollationKey is returned.
See Also:
CollationKey, compare(java.lang.String, java.lang.String)

equals

public boolean equals(java.lang.String source,
                      java.lang.String target)
Convenience method for comparing the equality of two strings based on this Collator's collation rules.
Overrides:
equals in class java.text.Collator
Parameters:
source - the source string to be compared with.
target - the target string to be compared with.
Returns:
true if the strings are equal according to the collation rules, false otherwise.
See Also:
compare(java.lang.String, java.lang.String)

getStrength

public int getStrength()
Returns this Collator's strength property. The strength property determines the minimum level of difference considered significant during comparison. See the Collator class description for an example of use.
Overrides:
getStrength in class java.text.Collator
Returns:
this Collator's current strength property.
See Also:
setStrength(int)

setStrength

public void setStrength(int newStrength)
Sets this Collator's strength property. The strength property determines the minimum level of difference considered significant during comparison. See the Collator class description for an example of use.
Overrides:
setStrength in class java.text.Collator
Parameters:
newStrength - the new strength value.
Throws:
java.lang.IllegalArgumentException - if the new strength value is not one of PRIMARY, SECONDARY, TERTIARY or IDENTICAL.
See Also:
getStrength()

getDecomposition

public int getDecomposition()
Get the decomposition mode of this Collator. Decomposition mode determines how Unicode composed characters are handled. Adjusting decomposition mode allows the user to select between faster and more complete collation behavior. The three values for decomposition mode are: See the documentation for these three constants for a description of their meaning.
Overrides:
getDecomposition in class java.text.Collator
Returns:
the decomposition mode
See Also:
setDecomposition(int)

setDecomposition

public void setDecomposition(int decompositionMode)
Set the decomposition mode of this Collator. See getDecomposition for a description of decomposition mode.
Overrides:
setDecomposition in class java.text.Collator
Parameters:
decompositionMode - the new decomposition mode
Throws:
java.lang.IllegalArgumentException - if the given value is not a valid decomposition mode.
See Also:
getDecomposition()

hashCode

public int hashCode()
Overrides:
hashCode in class java.text.Collator

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.text.Collator

toString

public java.lang.String toString()
Provides a string description of this object.
Overrides:
toString in class java.lang.Object

paramString

protected java.lang.StringBuffer paramString()