public class BinaryNLS
extends java.lang.Object
implements ej.nls.NLS
NLS
implementation uses a binary file as entry point. This binary file is encoded by the NLS PO addon
processor.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() |
java.lang.String |
getCurrentLocale() |
java.lang.String |
getDisplayName(java.lang.String locale) |
java.lang.String |
getMessage(int messageID) |
java.lang.String |
getMessage(int messageID,
java.lang.String locale) |
static ej.nls.NLS |
newBinaryNLS(java.lang.String nlsInterfaceName,
int keysCRC32)
Decodes a binary NLS file for the given interface.
|
void |
setCurrentLocale(java.lang.String 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 ej.nls.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)
getDisplayName
in interface ej.nls.NLS
public java.lang.String getMessage(int messageID)
getMessage
in interface ej.nls.NLS
public java.lang.String getMessage(int messageID, java.lang.String locale)
getMessage
in interface ej.nls.NLS
public void setCurrentLocale(java.lang.String locale)
setCurrentLocale
in interface ej.nls.NLS
public java.lang.String[] getAvailableLocales()
getAvailableLocales
in interface ej.nls.NLS
public java.lang.String getCurrentLocale()
getCurrentLocale
in interface ej.nls.NLS