Package org.apache.sis.util
Class SimpleInternationalString
java.lang.Object
org.apache.sis.util.AbstractInternationalString
org.apache.sis.util.SimpleInternationalString
- All Implemented Interfaces:
Serializable
,CharSequence
,Comparable<org.opengis.util.InternationalString>
,Formattable
,org.opengis.util.InternationalString
- Direct Known Subclasses:
AbstractName.International
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.
Instantiation
If the characters sequence to wrap is known to be aString
instance, then
the SimpleInternationalString(String)
constructor is okay. Otherwise use
the Types.toInternationalString(CharSequence)
method.
Immutability and thread safety
This class is immutable and thus inherently thread-safe. Subclasses may or may not be immutable, at implementation choice. But implementers are encouraged to make sure that subclasses remain immutable for more predictable behavior.- Since:
- 1.1
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Serial number for inter-operability with different versions.Fields inherited from class org.apache.sis.util.AbstractInternationalString
defaultValue
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance from the given string. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this international string with the specified object for equality.int
hashCode()
Returns a hash code value for this international text.private void
Reads the string.toString()
Returns the string representation, which is unique for all locales.Returns the same string for all locales.private void
Writes the string.Methods inherited from class org.apache.sis.util.AbstractInternationalString
charAt, compareTo, formatTo, length, subSequence
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
-
Constructor Details
-
SimpleInternationalString
Creates a new instance from the given string. If the type of the text to wrap is the more genericCharSequence
interface, then use theTypes.toInternationalString(CharSequence)
method instead.- Parameters:
text
- the string for all locales.
-
-
Method Details
-
toString
Returns the string representation, which is unique for all locales.- Specified by:
toString
in interfaceCharSequence
- Specified by:
toString
in interfaceorg.opengis.util.InternationalString
- Overrides:
toString
in classAbstractInternationalString
- Returns:
- the string in the default locale.
-
toString
Returns the same string for all locales. This is the string given to the constructor.- Specified by:
toString
in interfaceorg.opengis.util.InternationalString
- Specified by:
toString
in classAbstractInternationalString
- Parameters:
locale
- ignored in theSimpleInternationalString
implementation.- Returns:
- the international string as a
String
. - See Also:
-
equals
Compares this international string with the specified object for equality. -
hashCode
public int hashCode()Returns a hash code value for this international text. -
writeObject
Writes the string. This is required sinceAbstractInternationalString.defaultValue
is not serialized.- Parameters:
out
- the output stream where to serialize this international string.- Throws:
IOException
- if an I/O error occurred while writing.
-
readObject
Reads the string. This is required sinceAbstractInternationalString.defaultValue
is not serialized.- Parameters:
in
- the input stream from which to deserialize an international string.- Throws:
IOException
- if an I/O error occurred while reading or if the stream contains invalid data.ClassNotFoundException
- if the class serialized on the stream is not on the classpath.
-