public abstract class AbstractInternationalString extends Object implements InternationalString, Formattable
InternationalString
interface is used as a replacement
for the String
class 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-wide default locale.
The natural ordering is defined by the value returned by
toString()
.
Defined in the sis-utility
module
Modifier | Constructor and Description |
---|---|
protected |
AbstractInternationalString()
Constructs an international string.
|
Modifier and Type | Method and Description |
---|---|
char |
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.
|
void |
formatTo(Formatter formatter,
int flags,
int width,
int precision)
Formats this international string using the given formatter.
|
int |
length()
Returns the length of the string in the default locale.
|
CharSequence |
subSequence(int start,
int end)
Returns a subsequence of the string in the default locale.
|
String |
toString()
Returns this string in the default locale.
|
abstract String |
toString(Locale locale)
Returns this string in the given locale.
|
protected AbstractInternationalString()
public int length()
toString()
.length
in interface CharSequence
public char charAt(int index) throws IndexOutOfBoundsException
toString()
.charAt
in interface CharSequence
index
- The index of the character.IndexOutOfBoundsException
- if the specified index is out of bounds.public CharSequence subSequence(int start, int end)
String
object starting with the character value at the specified
index and ending with the character value at index end - 1
.subSequence
in interface CharSequence
start
- The start index, inclusive.end
- The end index, exclusive.IndexOutOfBoundsException
- if start
or end
is out of range.public abstract String toString(Locale locale)
toString()
method.
Locale.ROOT
argument valueLocale.ROOT
can be given to this method for requesting a "unlocalized" string,
typically some programmatic values like enumerations or identifiers. While identifiers
often look like English words, Locale.ROOT
is not considered synonymous to
Locale.ENGLISH
because the values may differ in the way numbers and dates are
formatted (e.g. using the ISO 8601 standard for dates instead than English conventions).
null
argument valueLocale.ROOT
constant is new in Java 6. Some other libraries designed for Java 5
use the null
value for "unlocalized" strings. Apache SIS accepts null
value
for inter-operability with those libraries. However the behavior is implementation dependent:
some subclasses will take null
as a synonymous of the system default locale, while
other subclasses will take null
as a synonymous of the root locale. In order to
ensure determinist behavior, client code are encouraged to specify only non-null values.toString
in interface InternationalString
locale
- The desired locale for the string to be returned.Locale.getDefault()
,
Locale.ROOT
public String toString()
toString(Locale.getDefault())
.
All methods from CharSequence
operate on this string.
This string is also used as the criterion for natural ordering.
toString
in interface CharSequence
toString
in interface InternationalString
toString
in class Object
public void formatTo(Formatter formatter, int flags, int width, int precision)
toString(formatter.Formatter.locale())
formatTo
in interface Formattable
formatter
- The formatter to use for formatting this string.flags
- A bitmask of FormattableFlags
values.width
- The minimum number of characters, or -1 if none.precision
- The maximum number of characters (before expanding to the width
),
or -1 for no restriction.public int compareTo(InternationalString object)
toString()
.compareTo
in interface Comparable<InternationalString>
object
- The string to compare with this string.Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.