javax.rad.util
Class TranslationMap

java.lang.Object
  extended by javax.rad.util.TranslationMap

public class TranslationMap
extends Object

Translation is for translating labels or label keys in any language. It supports wild card translation. This is supported in a very fast implementation. Translation examples: "Helo *, how are you?", "Hallo *, wie geht es Dir?" translates "Helo Lisa, how are you?" to "Hallo Lisa, wie geht es Dir?".


Constructor Summary
TranslationMap()
          Constructs a new translation map.
 
Method Summary
 void clear()
          Clears all translations.
 String get(String pText)
          Gets the configured translation for the given text.
 Properties getAsProperties()
          Gets this TranslationMap as Properties.
 String getLanguage()
          Gets the language code of the translated texts.
 TranslationMap getParent()
          Gets the Parent TranslationMap to delegate translations.
 List<String> getUntranslated()
          Gets all the untranslated texts.
 Enumeration<String> keys()
          Gets all translation map texts.
 long lastModified()
          Gets the last modified time.
 String put(String pText, String pTranslation)
          Puts a new translation.
 void setAsProperties(Properties pProperties)
          Sets this TranslationMap as Properties.
 void setLanguage(String pLanguage)
          Sets the language code of the translated texts.
 void setParent(TranslationMap pParent)
          Sets the Parent TranslationMap to delegate translations.
 int size()
          The size of the translation map.
 String translate(String pText)
          Translates the text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslationMap

public TranslationMap()
Constructs a new translation map.

Method Detail

getParent

public TranslationMap getParent()
Gets the Parent TranslationMap to delegate translations.

Returns:
the Parent TranslationMap to delegate translations.

setParent

public void setParent(TranslationMap pParent)
Sets the Parent TranslationMap to delegate translations.

Parameters:
pParent - the Parent TranslationMap to delegate translations.
Throws:
IllegalArgumentException - if parent is not allowed

translate

public String translate(String pText)
Translates the text.

Parameters:
pText - the text to translate.
Returns:
the translated text.

put

public String put(String pText,
                  String pTranslation)
Puts a new translation.

Parameters:
pText - the text to translate.
pTranslation - the translation.
Returns:
the previous translation.

keys

public Enumeration<String> keys()
Gets all translation map texts.

Returns:
all translation map texts.

get

public String get(String pText)
Gets the configured translation for the given text.

Parameters:
pText - the text.
Returns:
the configured translation for the given text.

size

public int size()
The size of the translation map.

Returns:
the size of the translation map.

clear

public void clear()
Clears all translations.


getUntranslated

public List<String> getUntranslated()
Gets all the untranslated texts.

Returns:
the untranslated texts.

getAsProperties

public Properties getAsProperties()
Gets this TranslationMap as Properties.

Returns:
this TranslationMap as Properties.

setAsProperties

public void setAsProperties(Properties pProperties)
Sets this TranslationMap as Properties.

Parameters:
pProperties - the Properties.

setLanguage

public void setLanguage(String pLanguage)
Sets the language code of the translated texts.

Parameters:
pLanguage - the language code e.g. "en"

getLanguage

public String getLanguage()
Gets the language code of the translated texts.

Returns:
the language code e.g. "en"

lastModified

public long lastModified()
Gets the last modified time.

Returns:
the last modified time in millis


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.