Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_IMPLEMENTATION_ERROR
Error code when default implementation cannot be instantiated.
|
static int |
MISSING_BINARY
Error code when binary is missing.
|
static java.lang.String |
NLS_DEFAULT_IMPLEMENTATION
Property which allows to define a fallback NLS implementation.
|
static java.lang.String |
NLS_DEFAULT_LOCALE
Property which allows to fix the default locale at compiletime.
|
static int |
REQUIRED_IMPLEMENTATION_ERROR
Error code when required implementation cannot be instantiated.
|
static int |
WRONG_CRC
Error code when binary is incompatible: wrong CRC.
|
static int |
WRONG_FORMAT_VERSION
Error code when binary is incompatible: wrong format version.
|
static int |
WRONG_HEADER
Error code when binary is incompatible: wrong header.
|
Constructor and Description |
---|
BinaryNLS(java.lang.Class<? extends java.lang.Object> nlsInterface,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
BinaryNLS(java.lang.String nlsInterfaceName,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getAvailableLocales()
Gets the list of available locales.
|
java.lang.String |
getCurrentLocale()
Gets the current locale.
|
java.lang.String |
getDisplayName(java.lang.String locale)
Gets the human-readable name of the given locale.
|
java.lang.String |
getMessage(int messageID)
Gets the message matching an ID in the current language.
|
java.lang.String |
getMessage(int messageID,
java.lang.String locale)
Gets the message matching an ID in a specific language.
|
static NLS |
newBinaryNLS(java.lang.String nlsInterfaceName,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
void |
setCurrentLocale(java.lang.String locale)
Changes the current locale.
|
public static final java.lang.String NLS_DEFAULT_LOCALE
public static final java.lang.String NLS_DEFAULT_IMPLEMENTATION
newBinaryNLS(String, int)
,
Constant Field Valuespublic static final int MISSING_BINARY
public static final int WRONG_HEADER
public static final int WRONG_FORMAT_VERSION
public static final int WRONG_CRC
public static final int DEFAULT_IMPLEMENTATION_ERROR
public static final int REQUIRED_IMPLEMENTATION_ERROR
public BinaryNLS(java.lang.String nlsInterfaceName, int keysCRC32) throws java.io.IOException
nlsInterfaceName
- the name of the NLS interface which lists the messages ID.keysCRC32
- the CRC32 of all messages keys. This allows to verify the coherence between the encoded messages and
the given interface. This CRC32 is a field of the given interface.java.io.IOException
- if the expected binary file is not available in application classpath or if the binary file content
is not recognized (probably because not encoded by the Binary NLS addon processor).java.lang.IllegalArgumentException
- if the default locale defined by the property NLS_DEFAULT_LOCALE
is not available in the
binary file.public BinaryNLS(java.lang.Class<? extends java.lang.Object> nlsInterface, int keysCRC32) throws java.io.IOException
nlsInterface
- the NLS interface which lists the messages ID.keysCRC32
- the CRC32 of all messages keys. This allows to verify the coherence between the encoded messages and
the given interface. This CRC32 is a field of the given interface.java.io.IOException
- if the expected binary file is not available in application classpath or if the binary file content
is not recognized (probably because not encoded by the Binary NLS addon processor).java.lang.IllegalArgumentException
- if the default locale defined by the property NLS_DEFAULT_LOCALE
is not available in the
binary file.@Nullable public static NLS newBinaryNLS(java.lang.String nlsInterfaceName, int keysCRC32)
If an error occurs while creating the NLS, a default NLS implementation instance is returned if the property
NLS_DEFAULT_IMPLEMENTATION
is defined, otherwise, null
is returned.
nlsInterfaceName
- the name of the NLS interface which lists the messages ID.keysCRC32
- the CRC32 of all messages keys.java.lang.IllegalArgumentException
- if the default implementation cannot be instantiated.BinaryNLS(String, int)
public java.lang.String getDisplayName(java.lang.String locale)
NLS
getDisplayName
in interface NLS
locale
- the locale.public java.lang.String getMessage(int messageID)
NLS
getMessage
in interface NLS
messageID
- the ID of the message to retrieve.public java.lang.String getMessage(int messageID, java.lang.String locale)
NLS
getMessage
in interface NLS
messageID
- the ID of the message to retrieve.locale
- the locale to use.public void setCurrentLocale(java.lang.String locale)
NLS
setCurrentLocale
in interface NLS
locale
- the locale to set.public java.lang.String[] getAvailableLocales()
NLS
getAvailableLocales
in interface NLS
public java.lang.String getCurrentLocale()
NLS
getCurrentLocale
in interface NLS