public final class ResourceText
extends java.lang.Object
The markup "Text" defines an association to a "key" with some text. The parameter "key" specify the text key. The text
between opening and closing markup "Text" is the corresponding text in the specific
language.Modifier and Type | Field and Description |
---|---|
private java.util.Hashtable<java.lang.String,java.lang.String> |
keysText
Hash map of key, text
|
private java.util.Locale |
locale
Actual locale
|
private Resources |
resources
Resources reference
|
private java.util.ArrayList<ResourceTextListener> |
resourceTextListeners
List of listener to alert in language change
|
private static java.lang.String |
XML
XML extension
|
private java.lang.String |
xmlReferencePathHeader
Path of default XML, without .xml
|
Constructor and Description |
---|
ResourceText(Resources resources,
java.lang.String xmlReferencePathHeader)
Create a new instance of ResourceText
|
Modifier and Type | Method and Description |
---|---|
private void |
fillKeysText(java.lang.String path)
Fill the hash map of key, text with the content of given resource
|
java.util.Locale |
getLocale()
Actual locale
|
java.lang.String |
getText(java.lang.String key)
Obtain a text
|
java.lang.String |
getXmlReferencePathHeader()
Path of default XML, without .xml
|
void |
register(ResourceTextListener resourceTextListener)
Register a listener to be alert when language change
|
void |
setLocale(java.util.Locale locale)
Change the language
|
void |
unregister(ResourceTextListener resourceTextListener)
Unregister a listener to be no more alert when language change
|
private static final java.lang.String XML
private final java.util.Hashtable<java.lang.String,java.lang.String> keysText
private java.util.Locale locale
private final Resources resources
private final java.util.ArrayList<ResourceTextListener> resourceTextListeners
private final java.lang.String xmlReferencePathHeader
ResourceText(Resources resources, java.lang.String xmlReferencePathHeader)
resources
- Resources referencexmlReferencePathHeader
- Path of default XML, without .xmlprivate void fillKeysText(java.lang.String path)
path
- Resource to parsepublic java.util.Locale getLocale()
public java.lang.String getText(java.lang.String key)
key
- Text keypublic java.lang.String getXmlReferencePathHeader()
public void register(ResourceTextListener resourceTextListener)
resourceTextListener
- Listener to registerpublic void setLocale(java.util.Locale locale)
locale
- New languagepublic void unregister(ResourceTextListener resourceTextListener)
resourceTextListener
- Listener to unregister