Class ResourceInternationalString
java.lang.Object
org.apache.sis.util.AbstractInternationalString
org.apache.sis.util.resources.ResourceInternationalString
- All Implemented Interfaces:
Serializable, CharSequence, Comparable<org.opengis.util.InternationalString>, Formattable, org.opengis.util.InternationalString
- Direct Known Subclasses:
Errors.International, Messages.International, Resources.International, Resources.International, Resources.International, Resources.International, Resources.International, Resources.International, Resources.International, Vocabulary.International
public abstract class ResourceInternationalString
extends AbstractInternationalString
implements Serializable
A copy of
ResourceInternationalString specialized for
IndexedResourceBundle. Compared to the public class, this specialization works
with integer resource keys and accepts arguments.
Immutability and thread safety
This base class is immutable and thus inherently thread-safe.- Since:
- 0.8
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectThe argument(s), ornullif none.private final booleantrueif the key has arguments.private shortThe key for the resource to fetch.private static final longSerial number for inter-operability with different versions. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedResourceInternationalString(short key) Creates a new international string for the given key.protectedResourceInternationalString(short key, Object arguments) Creates a new international string for the given key and arguments. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanCompares this international string with the specified object for equality.protected abstract IndexedResourceBundleReturns the resource bundle for the given locale.protected abstract KeyConstantsReturns a handler for the constants declared in the innerKeysclass.final inthashCode()Returns a hash code value for this international text.private voidDeserializes an object serialized bywriteObject(ObjectOutputStream).final LogRecordtoLogRecord(Level level) Converts this international string to a log record.final StringReturns a string in the specified locale.private voidSerializes this international string using the key name rather than numerical value.Methods inherited from class AbstractInternationalString
charAt, compareTo, formatTo, length, subSequence, toStringMethods inherited from interface CharSequence
chars, codePoints
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
key
private transient short keyThe key for the resource to fetch. -
hasArguments
private final boolean hasArgumentstrueif the key has arguments. Iffalse, then theargumentsfield shall be ignored. We cannot rely onnullarguments value because null may be a valid value. -
arguments
-
-
Constructor Details
-
ResourceInternationalString
protected ResourceInternationalString(short key) Creates a new international string for the given key.- Parameters:
key- the key for the resource to fetch.
-
ResourceInternationalString
Creates a new international string for the given key and arguments.- Parameters:
key- the key for the resource to fetch.arguments- the argument(s).
-
-
Method Details
-
getKeyConstants
Returns a handler for the constants declared in the innerKeysclass. This is used at serialization time in order to serialize the constant name rather than its numeric value.- Returns:
- a handler for the constants declared in the inner
Keysclass.
-
getBundle
Returns the resource bundle for the given locale.- Parameters:
locale- the locale for which to get the resource bundle, ornullfor the default locale.- Returns:
- the resource bundle for the given locale.
-
toLogRecord
-
toString
Returns a string in the specified locale.- Specified by:
toStringin interfaceorg.opengis.util.InternationalString- Specified by:
toStringin classAbstractInternationalString- Parameters:
locale- the desired locale for the string to be returned.- Returns:
- the string in the specified locale, or in a fallback locale.
- Throws:
MissingResourceException- if the key given to the constructor is invalid.- See Also:
-
equals
Compares this international string with the specified object for equality. TwoResourceInternationalStringare considered equal if they are of the same class and have been constructed with equal arguments. -
hashCode
-
writeObject
Serializes this international string using the key name rather than numerical value.- Parameters:
out- the output stream where to serialize this object.- Throws:
IOException- if an I/O error occurred while writing.
-
readObject
Deserializes an object serialized bywriteObject(ObjectOutputStream).- Parameters:
in- the input stream from which to deserialize an object.- 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.
-