All Packages Class Hierarchy This Package Previous Next Index
Class java.text.CollatedString
java.lang.Object
|
+----java.text.CollatedString
- public final class CollatedString
- extends Object
CollatedString gives you a convenient way to use international strings
in a hashtable or sorted collection. For example, take an array of
strings and a Collation for French, create the corresponding
CollatedStrings, sort them and then extract the original strings (now
in French sorted order).
Example of use:
CollatedString myStr = new ("This is a String", Collation.getDefault());
int myStrHash = myStr.hashCode();
Note : When compares two objects of different classes, the result will be
incorrect. For example, String object and CollatedString object cannot be
compared with CollatedString.equals(), CollatedString.greater, or
CollatedString.greaterOrEqual().
- See Also:
- Collation
-
CollatedString(String, Collation)
- The CollatedString constructor takes the string value and the
collation object to create the collated string with.
-
equals(Object)
- Compare if two objects are the same.
-
getCollation()
- Get the current collation object.
-
getString()
- Get the current string that the collated string represents.
-
greater(Object)
- Compare if this is greater than the source object.
-
greaterOrEqual(Object)
- Compare if this is greater than or equal to the source object.
-
hashCode()
- Returns the hash code of the string based on the collation rules.
-
setCollation(Collation)
- Set the current collation object to a new collation object.
-
setString(String)
- Change the current collated string value to a new string.
CollatedString
public CollatedString(String value,
Collation comparison)
- The CollatedString constructor takes the string value and the
collation object to create the collated string with. A collation
object defines how a string is collated internationally.
- Parameters:
- value - the string to be used to create the collated string with.
- comparison - the collation object.
setString
public void setString(String value)
- Change the current collated string value to a new string.
- Parameters:
- value - the new string to be used to create the collated string
with.
- See Also:
- getString
getString
public String getString()
- Get the current string that the collated string represents.
- Returns:
- the string value of the collated string.
- See Also:
- setString
setCollation
public void setCollation(Collation comparison)
- Set the current collation object to a new collation object. A
collation object defines how a string is collated internationally.
- Parameters:
- comparison - the new collation object.
- See Also:
- getCollation
getCollation
public Collation getCollation()
- Get the current collation object. A collation object defines how
a string is collated internationally.
- Returns:
- the collation object that is currently used by the collated
string.
- See Also:
- setCollation
hashCode
public int hashCode()
- Returns the hash code of the string based on the collation rules.
- Returns:
- the hash code of a collated string.
- Overrides:
- hashCode in class Object
- See Also:
- hashCode
equals
public boolean equals(Object source)
- Compare if two objects are the same.
- Parameters:
- source - collated string to compare to.
- Returns:
- true if this is equal to source, false otherwise.
If source is not a CollatedString object, return false.
- Overrides:
- equals in class Object
greater
public boolean greater(Object source)
- Compare if this is greater than the source object.
- Parameters:
- source - collated string to compare to.
- Returns:
- true if this is greater than source, false otherwise.
If source is not a CollatedString object, return false.
greaterOrEqual
public boolean greaterOrEqual(Object source)
- Compare if this is greater than or equal to the source object.
- Parameters:
- source - collated string to compare to
- Returns:
- true if this is greater than or equal to source, false
otherwise. If source is not a CollatedString object, return false.
All Packages Class Hierarchy This Package Previous Next Index