Class AbstractInternationalString

Object
AbstractInternationalString
All Implemented Interfaces:
CharSequence, Comparable<InternationalString>, InternationalString
Direct Known Subclasses:
GrowableInternationalString, ResourceInternationalString, SimpleInternationalString

public abstract class AbstractInternationalString extends Object implements InternationalString
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 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 by toString().
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index) throws IndexOutOfBoundsException
      Returns the character of the string in the default locale at the specified index. This is the character of the string returned by toString().
      Specified by:
      charAt in interface CharSequence
      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

      public CharSequence subSequence(int start, int end)
      Returns a subsequence of the string in the default locale. The subsequence is a String object starting with the character value at the specified index and ending with the character value at index end - 1.
      Specified by:
      subSequence in interface CharSequence
      Parameters:
      start - The start index, inclusive.
      end - The end index, exclusive.
      Returns:
      The specified subsequence.
      Throws:
      IndexOutOfBoundsException - if start or end is out of range.
    • toString

      public abstract String toString(Locale locale)
      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 interface InternationalString
      Parameters:
      locale - The desired locale for the string to be returned, or null for a string in the implementation default locale.
      Returns:
      The string in the given locale if available, or in the default locale otherwise.
    • toString

      public String toString()
      Returns this string in the default locale. Invoking this method is equivalent to invoking toString(Locale.getDefault()). All methods from CharSequence operate on this string. This string is also used as the criterion for natural ordering.
      Specified by:
      toString in interface CharSequence
      Specified by:
      toString in interface InternationalString
      Overrides:
      toString in class Object
      Returns:
      The string in the default locale.
    • compareTo

      public int compareTo(InternationalString object)
      Compares this string with the specified object for order. This method compare the string in the default locale, as returned by toString().
      Specified by:
      compareTo in interface Comparable<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.