Package org.geotools.util
Class AbstractInternationalString
Object
AbstractInternationalString
- All Implemented Interfaces:
CharSequence
,Comparable<InternationalString>
,InternationalString
- Direct Known Subclasses:
GrowableInternationalString
,ResourceInternationalString
,SimpleInternationalString
A string that has been internationalized into several locales. This class is
used as a replacement for the
String
type whenever an attribute needs to be internationalization capable. The
default value (as returned by toString()
and other CharSequence
methods} is the string in the
current system default.
The natural ordering is defined by the string in default
locale, as returned by toString()
. This string also defines the character
sequence.
- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) Returns the character of the string in the default locale at the specified index.int
compareTo
(InternationalString object) Compares this string with the specified object for order.int
length()
Returns the length of the string in the default locale.subSequence
(int start, int end) Returns a subsequence of the string in the default locale.toString()
Returns this string in the default locale.abstract String
Returns this string in the given locale.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
AbstractInternationalString
public AbstractInternationalString()Constructs an international string.
-
-
Method Details
-
length
public int length()Returns the length of the string in the default locale. This is the length of the string returned bytoString()
.- Specified by:
length
in interfaceCharSequence
-
charAt
Returns the character of the string in the default locale at the specified index. This is the character of the string returned bytoString()
.- Specified by:
charAt
in interfaceCharSequence
- Parameters:
index
- The index of the character.- Returns:
- The character at the specified index.
- Throws:
IndexOutOfBoundsException
- if the specified index is out of bounds.
-
subSequence
Returns a subsequence of the string in the default locale. The subsequence is aString
object starting with the character value at the specified index and ending with the character value at indexend - 1
.- Specified by:
subSequence
in interfaceCharSequence
- Parameters:
start
- The start index, inclusive.end
- The end index, exclusive.- Returns:
- The specified subsequence.
- Throws:
IndexOutOfBoundsException
- ifstart
orend
is out of range.
-
toString
Returns this string in the given locale. If no string is available in the given locale, then some default locale is used. The default locale is implementation-dependent. It may or may not be the system default).- Specified by:
toString
in interfaceInternationalString
- Parameters:
locale
- The desired locale for the string to be returned, ornull
for a string in the implementation default locale.- Returns:
- The string in the given locale if available, or in the default locale otherwise.
-
toString
Returns this string in the default locale. Invoking this method is equivalent to invokingtoString(Locale.getDefault())
. All methods fromCharSequence
operate on this string. This string is also used as the criterion for natural ordering.- Specified by:
toString
in interfaceCharSequence
- Specified by:
toString
in interfaceInternationalString
- Overrides:
toString
in classObject
- Returns:
- The string in the default locale.
-
compareTo
Compares this string with the specified object for order. This method compare the string in the default locale, as returned bytoString()
.- Specified by:
compareTo
in interfaceComparable<InternationalString>
- Parameters:
object
- The string to compare with this string.- Returns:
- A negative number if this string is before the given string, a positive number if after, or 0 if equals.
-