javax.rad.util
Class TranslationMap

java.lang.Object
  extended by javax.rad.util.TranslationMap
All Implemented Interfaces:
ITranslator

public class TranslationMap
extends java.lang.Object
implements ITranslator

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.
 java.lang.String get(java.lang.String pText)
          Gets the configured translation for the given text.
 java.util.Properties getAsProperties()
          Gets this TranslationMap as Properties.
 java.lang.String getLanguage()
          Gets the language code of the translated texts.
 TranslationMap getParent()
          Gets the Parent TranslationMap to delegate translations.
 java.lang.String getResourcePath()
          Gets the resource path.
 java.util.List<java.lang.String> getUntranslated()
          Gets all the untranslated texts.
 java.util.Enumeration<java.lang.String> keys()
          Gets all translation map texts.
 long lastModified()
          Gets the last modified time.
 java.lang.String put(java.lang.String pText, java.lang.String pTranslation)
          Puts a new translation.
 void setAsProperties(java.util.Properties pProperties)
          Sets this TranslationMap as Properties.
 void setLanguage(java.lang.String pLanguage)
          Sets the language code of the translated texts.
 void setParent(TranslationMap pParent)
          Sets the Parent TranslationMap to delegate translations.
 void setResourcePath(java.lang.String pPath)
          Sets the resource path as additional information, if known.
 int size()
          The size of the translation map.
 java.lang.String translate(java.lang.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:
java.lang.IllegalArgumentException - if parent is not allowed

translate

public java.lang.String translate(java.lang.String pText)
Translates the text.

Specified by:
translate in interface ITranslator
Parameters:
pText - the text to translate.
Returns:
the translated text.

put

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

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

keys

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

Returns:
all translation map texts.

get

public java.lang.String get(java.lang.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 java.util.List<java.lang.String> getUntranslated()
Gets all the untranslated texts.

Returns:
the untranslated texts.

getAsProperties

public java.util.Properties getAsProperties()
Gets this TranslationMap as Properties.

Returns:
this TranslationMap as Properties.

setAsProperties

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

Parameters:
pProperties - the Properties.

setLanguage

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

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

getLanguage

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

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

setResourcePath

public void setResourcePath(java.lang.String pPath)
Sets the resource path as additional information, if known.

Parameters:
pPath - the resource that contains the translation

getResourcePath

public java.lang.String getResourcePath()
Gets the resource path.

Returns:
the resource path or null if path is not known

lastModified

public long lastModified()
Gets the last modified time.

Returns:
the last modified time in millis


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.