org.geotoolkit.util
Class SimpleInternationalString

Object
  extended by AbstractInternationalString
      extended by SimpleInternationalString
All Implemented Interfaces:
Serializable, CharSequence, Comparable<InternationalString>, Formattable, InternationalString

@Immutable
public class SimpleInternationalString
extends AbstractInternationalString
implements Serializable

An international string consisting of a single string for all locales. For such a particular case, this implementation is more effective than other implementations provided in this package.

Since:
2.1
Version:
3.06
Author:
Martin Desruisseaux (IRD)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Constructor Summary
SimpleInternationalString(String message)
          Creates a new instance of international string.
 
Method Summary
 boolean equals(Object object)
          Compares this international string with the specified object for equality.
 int hashCode()
          Returns a hash code value for this international text.
 String toString()
          Returns the string representation, which is unique for all locales.
 String toString(Locale locale)
          Returns the same string for all locales.
static InternationalString[] wrap(CharSequence... strings)
          Returns the given array of CharSequences as an array of InternationalStrings.
static InternationalString wrap(CharSequence string)
          Returns the given characters sequence as an international string.
 
Methods inherited from class AbstractInternationalString
charAt, compareTo, formatTo, length, subSequence
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleInternationalString

public SimpleInternationalString(String message)
Creates a new instance of international string.

Parameters:
message - The string for all locales.
Method Detail

wrap

public static InternationalString wrap(CharSequence string)
Returns the given characters sequence as an international string. If the given sequence is null or an instance of InternationalString, this this method returns it unchanged. Otherwise, this method wraps the sequence in a new SimpleInternationalString instance and returns it.

Parameters:
string - The characters sequence to wrap, or null.
Returns:
The given sequence as an international string, or null if the given sequence was null.

wrap

public static InternationalString[] wrap(CharSequence... strings)
Returns the given array of CharSequences as an array of InternationalStrings. If the given array is null or an instance of InternationalString[], then this method returns it unchanged. Otherwise a new array of type InternationalString[] is created and every elements from the given array is wrapped in the new array.

If a defensive copy of the strings array is wanted, then the caller needs to check if the returned array is the same instance than the one given in argument to this method.

Parameters:
strings - The characters sequences to wrap, or null.
Returns:
The given array as an array of type InternationalString[], or null if the given array was null.
Since:
3.06

toString

public String toString()
Returns the string representation, which is unique for all locales.

Specified by:
toString in interface CharSequence
Specified by:
toString in interface InternationalString
Overrides:
toString in class AbstractInternationalString
Returns:
The string in the default locale.

toString

public String toString(Locale locale)
Returns the same string for all locales. This is the string given to the constructor.

Specified by:
toString in interface InternationalString
Specified by:
toString in class AbstractInternationalString
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.

equals

public boolean equals(Object object)
Compares this international string with the specified object for equality.

Overrides:
equals in class Object
Parameters:
object - The object to compare with this international string.
Returns:
true if the given object is equal to this string.

hashCode

public int hashCode()
Returns a hash code value for this international text.

Overrides:
hashCode in class Object


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.