|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<String,String>
skrueger.i8n.Translation
public class Translation
Represents a HashMap
of translations. toString() returns the
appropriate translation
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Field Summary | |
---|---|
static String |
DEFAULT_KEY
|
protected static List<PropertyChangeListener> |
listeners
|
static String |
LOCALECHANGE_PROPERTY
|
static String |
NO_TRANSLATION
|
Constructor Summary | |
---|---|
Translation()
Sometimes Translations are optional, like for keywords. |
|
Translation(List<String> languages,
String defaultTranslation)
Initializes a new Translation , an uses the given String to
initialize the Translation for all languages codes passed. |
|
Translation(String defaultTranslation)
Initializes a new Translation with a default translation if a
simple text is passed. |
Method Summary | |
---|---|
static void |
addLocaleChangeListener(PropertyChangeListener propertyChangeListener)
PropertyChangeListener can be registered to be informed when the
Locale changed. |
void |
addTranslationChangeListener(ActionListener actionListener)
|
Translation |
clone()
|
Translation |
copy(Translation backup)
Copy this Translation to another Translation e.g. for
editing |
static void |
fireLocaleChangeEvents()
Informs all registered PropertyChangeListener s about a change of
the the Locale . |
void |
fireTranslationChangedEvents(String lang)
|
void |
fromOneLine(String oneLineCoded)
Fills the Translation with the values coded into the String
Format of String is: "de{Baum}en{tree}"
If oneLineCoded is empty or null, NO TRANSLATION is set. |
static String |
getActiveLang()
Get the two-letter language sting that is active |
String |
put(String lang,
String value)
|
boolean |
removeTranslationChangeListener(ActionListener actionListener)
|
static void |
setActiveLang(String newLang)
Set up the Translation -system to use language. |
static void |
setActiveLang(String newLang,
boolean setDefaultLocale)
Set up the Translation -system to use language. |
String |
toOneLine()
Exports the Translations to a String of the Format: "de{Baum}en{tree}" |
String |
toString()
Returns the right translation by using the activeLang field. |
Methods inherited from class java.util.HashMap |
---|
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
public static final String LOCALECHANGE_PROPERTY
public static final String NO_TRANSLATION
public static final String DEFAULT_KEY
protected static List<PropertyChangeListener> listeners
Constructor Detail |
---|
public Translation(String defaultTranslation)
Translation
with a default translation if a
simple text is passed. If a "oneLine" text is parsed, it is interpreted.
Other translations may be added later - this is a HashMap
defaultTranslation
- Translation(List languages, String
defaultTranslation) {
public Translation(List<String> languages, String defaultTranslation)
Translation
, an uses the given String to
initialize the Translation
for all languages codes passed.
The translations can be changed later
public Translation()
Method Detail |
---|
public Translation clone()
clone
in class HashMap<String,String>
public static String getActiveLang()
public static void setActiveLang(String newLang)
Translation
-system to use language. If a change is
performed, events are fired to listeners. Nothing is done if the new
language equals the old language. The system's default locale is changed.
newLang
- The ISO Code of the new active languagepublic static void setActiveLang(String newLang, boolean setDefaultLocale)
Translation
-system to use language. If a change is
performed, events are fired to listeners. Nothing is done if the new
language equals the old language.
newLang
- The ISO Code of the new active languagesetDefaultLocale
- Shall the system's default locale be changed?public void fromOneLine(String oneLineCoded)
Translation
with the values coded into the String
Format of String
is: "de{Baum}en{tree}"
public String toOneLine()
public String toString()
activeLang
field. If
no translation is set, an ugly String NO_TRANSLATION
will re
returned. This might be changed for the final release. If the correct
language was not found, any entry in the Translation
HashMap
will be returned, that contains more than an empty
string.
toString
in class AbstractMap<String,String>
public Translation copy(Translation backup)
Translation
to another Translation
e.g. for
editing
Translation
public static void addLocaleChangeListener(PropertyChangeListener propertyChangeListener)
PropertyChangeListener
can be registered to be informed when the
Locale
changed.
propertyChangeListener
- public static void fireLocaleChangeEvents()
PropertyChangeListener
s about a change of
the the Locale
.
public void addTranslationChangeListener(ActionListener actionListener)
public boolean removeTranslationChangeListener(ActionListener actionListener)
public void fireTranslationChangedEvents(String lang)
public String put(String lang, String value)
put
in interface Map<String,String>
put
in class HashMap<String,String>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |