public class MessageCache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable<java.lang.String,Configuration> |
cachePagesByRange
Container for fast acquisition of locale dependent messages.
|
protected java.lang.String |
id
The desired domain identifier like "LIMA".
|
protected Locale |
locale
Supported locale consisting at least of a language code.
|
protected org.apache.commons.vfs2.FileObject |
path
The VFS directory with locale specific page files.
|
Constructor and Description |
---|
MessageCache()
Constructor method for i18n purposes only.
|
MessageCache(Locale locale,
java.lang.String id,
org.apache.commons.vfs2.FileObject path)
Constructor method.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize()
Cares for proper cleanup when is not needed any longer (helps gc).
|
java.lang.String |
getMessage(java.lang.String code,
boolean prefix)
Returns the message text associated with a certain message code.
|
boolean |
isArmed()
Have the underlying message codes been successfully loaded?
|
void |
loadAllPages()
Load all available message code pages for the represented locale.
|
protected java.util.Hashtable<java.lang.String,Configuration> cachePagesByRange
String
) like "0100", value is page container (Configuration
).protected Locale locale
protected java.lang.String id
protected org.apache.commons.vfs2.FileObject path
public MessageCache() throws java.lang.InstantiationException
I18NExtractor
).
java.lang.InstantiationException
- Error indicationpublic MessageCache(Locale locale, java.lang.String id, org.apache.commons.vfs2.FileObject path)
locale
- The locale to load the messages forid
- The desired domain identifier like "LIMA"path
- The VFS directory with locale specific page filesjava.lang.IllegalArgumentException
- Error indicationprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- Error indicationpublic java.lang.String getMessage(java.lang.String code, boolean prefix)
NullPointerException
if code
is null
.
If the message text cannot be found for the specified code and locale
then null
is returned and it's up to the caller to react appropriately e.g. by
acquiring the message text in a default language like English.
You can either pass code
as numerical string like "0001" (four places), or as
full code including the domain identifier prefix like "LIMA-0001" which is used for the
configuration files as property name.
With the parameter prefix
you can specify whether to have the domain identifier
automatically prepended (like "LIMA-0000: Unknown message identifier", or to get the plain
message text (like "Unknown message identifier").
code
- The message code of interest, don't pass null
valuesprefix
- Shall the domain identifier be automatically prepended to the message?null
if code does not existpublic boolean isArmed()
public void loadAllPages()
Copyright © 2005-2023 Leisenfels GmbH. All rights reserved.