public class BinaryNLS
extends java.lang.Object
implements ej.nls.NLS
NLS
implementation uses a binary file as entry point. Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_IMPLEMENTATION_ERROR
Error code when default implementation cannot be instantiated.
|
static int |
FORM_INDEX_OUT_OF_BOUNDS_ERROR
Error code when the plural form index resulting from a plural expression is negative or larger than the number of
available forms for the locale.
|
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.
|
static int |
WRONG_LOCALE_INDEX
Error code when the provided locale index does not correspond to an available one.
|
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.
|
BinaryNLS(java.lang.String nlsInterfaceName,
int keysCRC32,
NLSPlural pluralInfo)
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) |
static java.lang.String |
getErrorMessage(int errorCode)
Builds a Severe-level error message.
|
java.lang.String |
getMessage(int messageID) |
java.lang.String |
getMessage(int messageID,
int count) |
java.lang.String |
getMessage(int messageID,
int count,
java.lang.String locale) |
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.
|
static ej.nls.NLS |
newBinaryNLS(java.lang.String nlsInterfaceName,
int keysCRC32,
NLSPlural pluralInfo)
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 static final int WRONG_LOCALE_INDEX
public static final int FORM_INDEX_OUT_OF_BOUNDS_ERROR
public BinaryNLS(java.lang.String nlsInterfaceName, int keysCRC32, @Nullable NLSPlural pluralInfo) 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.pluralInfo
- an instance of NLSPlural containing the necessary information for plural messages management, can be
null if there are no plural messages in an 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.String nlsInterfaceName, int keysCRC32) throws java.io.IOException
No NLSPlural plural form processing class will be provided, all messages will be considered as singular form only.
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, NLSPlural pluralInfo)
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.pluralInfo
- an instance of NLSPlural containing the necessary information for plural messages management, can be
null if there are no plural messages in an interface.java.lang.IllegalArgumentException
- if the default implementation cannot be instantiated.BinaryNLS(String, int)
@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, int count)
getMessage
in interface ej.nls.NLS
public java.lang.String getMessage(int messageID, java.lang.String locale)
getMessage
in interface ej.nls.NLS
public java.lang.String getMessage(int messageID, int count, 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
public static java.lang.String getErrorMessage(int errorCode)
errorCode
- The error code.