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 String |
NLS_DEFAULT_IMPLEMENTATION
Property which allows to define a fallback NLS implementation.
|
static 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(Class<? extends Object> nlsInterface,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
BinaryNLS(String nlsInterfaceName,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getAvailableLocales()
Gets the list of available locales.
|
String |
getCurrentLocale()
Gets the current locale.
|
String |
getDisplayName(String locale)
Gets the human-readable name of the given locale.
|
String |
getMessage(int messageID)
Gets the message matching an ID in the current language.
|
String |
getMessage(int messageID,
String locale)
Gets the message matching an ID in a specific language.
|
static NLS |
newBinaryNLS(String nlsInterfaceName,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
void |
setCurrentLocale(String locale)
Changes the current locale.
|
public static final int DEFAULT_IMPLEMENTATION_ERROR
public static final int MISSING_BINARY
public static final String NLS_DEFAULT_IMPLEMENTATION
newBinaryNLS(String, int)
,
Constant Field Valuespublic static final String NLS_DEFAULT_LOCALE
public static final int REQUIRED_IMPLEMENTATION_ERROR
public static final int WRONG_CRC
public static final int WRONG_FORMAT_VERSION
public static final int WRONG_HEADER
public BinaryNLS(Class<? extends Object> nlsInterface, int keysCRC32) throws 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.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).IllegalArgumentException
- if the default locale defined by the property NLS_DEFAULT_LOCALE
is not available in the
binary file.public BinaryNLS(String nlsInterfaceName, int keysCRC32) throws 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.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).IllegalArgumentException
- if the default locale defined by the property NLS_DEFAULT_LOCALE
is not available in the
binary file.public String[] getAvailableLocales()
NLS
getAvailableLocales
in interface NLS
public String getCurrentLocale()
NLS
getCurrentLocale
in interface NLS
public String getDisplayName(String locale)
NLS
getDisplayName
in interface NLS
locale
- the locale.public String getMessage(int messageID)
NLS
getMessage
in interface NLS
messageID
- the ID of the message to retrieve.public String getMessage(int messageID, String locale)
NLS
getMessage
in interface NLS
messageID
- the ID of the message to retrieve.locale
- the locale to use.@Nullable public static NLS newBinaryNLS(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.IllegalArgumentException
- if the default implementation cannot be instantiated.BinaryNLS(String, int)
public void setCurrentLocale(String locale)
NLS
setCurrentLocale
in interface NLS
locale
- the locale to set.