Package org.apache.sis.util.resources
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 Object
The argument(s), ornull
if none.private final boolean
true
if the key has arguments.private short
The key for the resource to fetch.private static final long
Serial number for inter-operability with different versions. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ResourceInternationalString
(short key) Creates a new international string for the given key.protected
ResourceInternationalString
(short key, Object arguments) Creates a new international string for the given key and arguments. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Compares this international string with the specified object for equality.protected abstract IndexedResourceBundle
Returns the resource bundle for the given locale.protected abstract KeyConstants
Returns a handler for the constants declared in the innerKeys
class.final int
hashCode()
Returns a hash code value for this international text.private void
Deserializes an object serialized bywriteObject(ObjectOutputStream)
.final LogRecord
toLogRecord
(Level level) Converts this international string to a log record.final String
Returns a string in the specified locale.private void
Serializes this international string using the key name rather than numerical value.Methods inherited from class org.apache.sis.util.AbstractInternationalString
charAt, compareTo, formatTo, length, subSequence, toString
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:
-
key
private transient short keyThe key for the resource to fetch. -
hasArguments
private final boolean hasArgumentstrue
if the key has arguments. Iffalse
, then thearguments
field shall be ignored. We cannot rely onnull
arguments value because null may be a valid value. -
arguments
The argument(s), ornull
if none. Note that the user may also really want to specifynull
as an argument value. We distinguish the two cases with the sign of thekey
value.
-
-
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 innerKeys
class. 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
Keys
class.
-
getBundle
Returns the resource bundle for the given locale.- Parameters:
locale
- the locale for which to get the resource bundle, ornull
for the default locale.- Returns:
- the resource bundle for the given locale.
-
toLogRecord
Converts this international string to a log record.- Parameters:
level
- the logging level.- Returns:
- a log record with the message of this international string.
- Since:
- 1.0
-
toString
Returns a string in the specified locale.- Specified by:
toString
in interfaceorg.opengis.util.InternationalString
- Specified by:
toString
in 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. TwoResourceInternationalString
are considered equal if they are of the same class and have been constructed with equal arguments. -
hashCode
public final int hashCode()Returns a hash code value for this international text. -
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.
-