All Packages Class Hierarchy This Package Previous Next Index
Class multilizer.Dictionary
java.lang.Object
|
+----multilizer.Dictionary
- public abstract class Dictionary
- extends Object
- implements StringTranslator, Serializable
An abstract component for accessing the dictionary data.
Dictionary contains the language and translation data.
The language data contains the information of each language of the dictionary.
The translataion data contains the translation of each string in every supported language.
The first language can have a special meaning. This is the case when the language
code of the language is "". Such a language is called the native language.
It is the language you use to create the application/applet.
Native language is never active.
The next language (or the first if there is no native language) is the first real language, etc.
The Language
property sets the active language. If it is -1 the dictionary chooses the language
that matches best to the default locale of the system.
The ActiveLanguage
property gets the active language.
The Locale
property sets the active locale.
By default the Language and the Locale properties are bound
(i.e. if you change either one the other changes to match.)
You can break the binding by setting the
BindLocale
to false.
Dictionary is used to access and store translation data. It does not translate
any user interface elements. Use the
Translator object do that.
One or more translators can listen the dictionary. Whenever the language
of the dictionary changes it informs every attached translator about the change letting
them to translate their host objects. The listeners does not have to be a translator
but any object implementing the
DictionaryListener
interface.
If you derive a new dictionary from Dictionary class you have to implement
the following abstract methods:
- getLanguageCount
- getLanguageData
- translateString
Depending on the dictionary type you might also need to override
the following methods:
- open
- close
- languageChanged
To increase performance you might also need to override the following methods:
- getLanguageDatas
MULTILIZER contains several dictionary components. Choose the dictionary component that
meets your requirements. The following tree contains the dictionaries.
The abstract dictionaries are enclosed in brackets.
[Dictionary]
[BundleDictionary]
[FileDictionary]
BinaryDictionary
TextDictionary
[LoginDictionary]
DatabaseDictionary
ServerDictionary
TestDictionary
- See Also:
- BinaryDictionary, TextDictionary, ServerDictionary, DatabaseDictionary, TestDictionary, Translator, AppletTranslator, Module
-
BIND_LANGUAGE_TO_LOCALE
- Language is bound to Locale.
-
BIND_LOCALE_TO_LANGUAGE
- Locale is bound to Language.
-
BIND_NONE
- Language and Locale properties are not noy bound together.
-
CC_COMPONENT
- Dictionary uses the component context information.
-
CC_FLAT
- Dictionary does not use context information.
-
CC_FORM
- Dictionary uses the form context information.
-
CC_FULL
- Dictionary uses the full context information.
-
componentContext
- True if the dictionary uses the component context.
-
DEFAULT_LANGUAGE
-
-
dictionaries
- A vector that contains all the dictionary components that have been created.
-
EMU_EURO
- Only Euro is used.
-
EMU_EURO_AND_NATIONAL
- Euro and national currency are both used.
-
EMU_NATIONAL
- National currency is used.
-
EMU_NATIONAL_AND_EURO
- National currency is used in the every day life.
-
EMU_NONE
- Locale is not a EMU member
-
EURO
- Euro variant of the Locale class.
-
EURO_BUSINESS
- Euro locale variant is used starting on January 1, 1999
-
EURO_IGNORE
- Multilizer ignores Euro
-
EURO_NORMAL
- Euro locale variant is used starting on January 1, 2002
-
formContext
- True if the dictionary uses the form context.
-
MT_TAG_NATIVE
- Tag the native string if the translation can not be found.
-
MT_THROW_EXCEPTION
- Throw a RuntimeException if the translation can not be found.
-
MT_USE_EMPTY
- Use the empty string if the translation can not be found.
-
MT_USE_NATIVE
- Use the native string if the translation can not be found.
-
Dictionary()
- Creates a new dictionary.
-
addLanguageChangeListener(DictionaryListener)
- Adds the specified language change listener to receive language change events from this dictionary.
-
canBeOpened()
- Returns true if the dictionary can be opened.
-
checkTranslation(String, String)
- Returns the checked translation the given string.
-
close()
- Closes the dictionary.
-
decodeLocale(Locale)
- Returns the mapped locale
-
defaultTranslate(String)
- Returns the translations for the given string.
-
dispose()
- Removes the dictionary from the dictionary list and closes the dictionary.
-
doesSupportLocale(Locale)
- Returns true if the dictionary contains the language that the given locale uses.
-
doesSystemSupportLocale(Locale)
- Returns true if the system supports the given locale.
-
finalize()
- Disposes of this dictionary once it is no longer referenced.
-
findDictionary(String)
- Finds a dictionary by name.
-
getActiveLanguage()
- Gets the active language index.
-
getActiveLocale()
- Gets the active locale of the dictionary.
-
getApplet()
- Gets the host applet.
-
getAutoTranslate()
- Gets the auto translation.
-
getBinding()
- Gets the locale binding.
-
getCheckLanguage()
- Gets the language checking.
-
getCheckSupport()
- Gets the language checking.
-
getDefaultDictionary()
- Returns the default dictionary.
-
getDefaultLanguage()
- Gets the index of the default language.
-
getDictionary(int)
- Gets a dictionary by index.
-
getDictionary(String)
- Gets a dictionary by name.
-
getDictionaryName()
- Gets the name of the dictionary.
-
getEMUPhase()
- Returns the current phase of EMU (Economic and Monetary Union)
-
getEuro()
- Gets the Euro usage.
-
getLanguage()
- Gets the language index.
-
getLanguageCount()
- Gets the amount of the languages in the dictionary.
-
getLanguageData()
- Gets the current language.
-
getLanguageData(int)
- Gets the specified language.
-
getLanguageDatas()
- Gets the all languages.
-
getLanguageLocale()
- Gets the locale of the active language of the dictionary.
-
getLocale()
- Gets the locale of the dictionary.
-
getMissingTranslation()
- Gets the MissingTranslation property.
-
getTranslationCount()
- Returns the translation count.
-
getUpdateDefaultLocale()
- Gets the update default locale.
-
isComponentContext()
- Returns true if the dictionary uses the component context.
-
isEMUMember(Locale)
- Returns true if the given locale is a member of EMU (Economic and Monetary Union)
-
isFormContext()
- Returns true if the dictionary uses the form context.
-
isFullContext()
- Returns true if the dictionary uses the full context.
-
isLanguageBidirectional()
- Returns true if the active language is bidirectional (e.g.
-
isLanguageEuropean()
- Returns true if the active language is European.
-
isLanguageFarEastern()
- Returns true if the active language is Far Eastern.
-
isNoneContext()
- Returns true if the dictionary does not use any context.
-
isOpen()
- Returns true if the dictionary has been opened.
-
languageChanged(boolean, boolean)
- Dictionary calls this method after the current language has been changed.
-
localeToLanguage(Locale)
- Returns the language index that the given locale uses.
-
open()
- Opens the dictionary.
-
removeLanguageChangeListener(DictionaryListener)
- Removes the language change listener so it no longer receives language change events from this dictionary.
-
setApplet(Applet)
- Sets the host applet.
-
setAutoTranslate(boolean)
- Sets the auto translation.
-
setBinding(int)
- Sets the locale binding.
-
setCheckLanguage(boolean)
- Sets the language checking.
-
setCheckSupport(boolean)
- Sets the language checking.
-
setContextCode(int)
- Sets the context code.
-
setDictionaryName(String)
- Sets the name of the dictionary.
-
setEuro(int)
- Sets the Euro usage.
-
setLanguage(int)
- Sets the current language index.
-
setLocale(Locale)
- Sets the locale of the dictionary.
-
setMissingTranslation(int)
- Sets the MissingTranslation property.
-
setUpdateDefaultLocale(boolean)
- Sets the update default locale.
-
translate(String)
- Returns the translations for the given string.
-
translate(String, String, String)
- Returns the translations for the given context sensitive string.
-
translateString(String)
- Returns the translation of the native string in the current language.
-
translateString(String, String, String)
- Returns the translation of the context sensitive native string in the current language.
DEFAULT_LANGUAGE
public static final int DEFAULT_LANGUAGE
CC_FLAT
public static final int CC_FLAT
- Dictionary does not use context information.
Each string is identified by its native value.
CC_FULL
public static final int CC_FULL
- Dictionary uses the full context information.
Each string is identified by its native value, form type, and component name.
CC_COMPONENT
public static final int CC_COMPONENT
- Dictionary uses the component context information.
Each string is identified by its native value and component name.
CC_FORM
public static final int CC_FORM
- Dictionary uses the form context information.
Each string is identified by its native value and form type.
BIND_NONE
public static final int BIND_NONE
- Language and Locale properties are not noy bound together.
BIND_LOCALE_TO_LANGUAGE
public static final int BIND_LOCALE_TO_LANGUAGE
- Locale is bound to Language.
This means that if you change the language the locale changes to match the new value.
BIND_LANGUAGE_TO_LOCALE
public static final int BIND_LANGUAGE_TO_LOCALE
- Language is bound to Locale.
This means that if you change the locale the language changes to match the value.
EURO
public static final String EURO
- Euro variant of the Locale class.
EURO_NORMAL
public static final int EURO_NORMAL
- Euro locale variant is used starting on January 1, 2002
EURO_BUSINESS
public static final int EURO_BUSINESS
- Euro locale variant is used starting on January 1, 1999
EURO_IGNORE
public static final int EURO_IGNORE
- Multilizer ignores Euro
EMU_NONE
public static final int EMU_NONE
- Locale is not a EMU member
EMU_NATIONAL
public static final int EMU_NATIONAL
- National currency is used.
Date is before January 1, 1999
EMU_NATIONAL_AND_EURO
public static final int EMU_NATIONAL_AND_EURO
- National currency is used in the every day life.
Euro is used in business.
Date is between January 1, 1999 and January 1, 2002.
EMU_EURO_AND_NATIONAL
public static final int EMU_EURO_AND_NATIONAL
- Euro and national currency are both used.
Date is between January 1, 2002 and July 1, 2002.
EMU_EURO
public static final int EMU_EURO
- Only Euro is used. Date is July 1, 2002 or later.
MT_USE_NATIVE
public static final int MT_USE_NATIVE
- Use the native string if the translation can not be found.
- See Also:
- MT_USE_EMPTY, MT_TAG_NATIVE, MT_THROW_EXCEPTION
MT_USE_EMPTY
public static final int MT_USE_EMPTY
- Use the empty string if the translation can not be found.
- See Also:
- MT_USE_NATIVE, MT_TAG_NATIVE, MT_THROW_EXCEPTION
MT_TAG_NATIVE
public static final int MT_TAG_NATIVE
- Tag the native string if the translation can not be found.
For example "house" is tagged to "@house@"
- See Also:
- MT_USE_NATIVE, MT_USE_EMPTY, MT_THROW_EXCEPTION
MT_THROW_EXCEPTION
public static final int MT_THROW_EXCEPTION
- Throw a RuntimeException if the translation can not be found.
- See Also:
- MT_USE_NATIVE, MT_USE_EMPTY, MT_TAG_NATIVE
formContext
protected transient boolean formContext
- True if the dictionary uses the form context.
componentContext
protected transient boolean componentContext
- True if the dictionary uses the component context.
dictionaries
public static Vector dictionaries
- A vector that contains all the dictionary components that have been created.
Dictionary
public Dictionary()
- Creates a new dictionary.
finalize
protected void finalize()
- Disposes of this dictionary once it is no longer referenced.
- Overrides:
- finalize in class Object
dispose
public void dispose()
- Removes the dictionary from the dictionary list and closes the dictionary.
isLanguageEuropean
public boolean isLanguageEuropean()
- Returns true if the active language is European.
isLanguageBidirectional
public boolean isLanguageBidirectional()
- Returns true if the active language is bidirectional (e.g. Arabic or Hebrew).
isLanguageFarEastern
public boolean isLanguageFarEastern()
- Returns true if the active language is Far Eastern.
isEMUMember
public static boolean isEMUMember(Locale locale)
- Returns true if the given locale is a member of EMU (Economic and Monetary Union)
- See Also:
- getEMUPhase
getEMUPhase
public static int getEMUPhase()
- Returns the current phase of EMU (Economic and Monetary Union)
- See Also:
- isEMUMember, EMU_NATIONAL, EMU_NATIONAL_AND_EURO, EMU_EURO_AND_NATIONAL, EMU_EURO
setEuro
public void setEuro(int value)
- Sets the Euro usage.
- See Also:
- getEuro, EURO_NORMAL, EURO_BUSINESS, EURO_IGNORE
getEuro
public int getEuro()
- Gets the Euro usage.
- See Also:
- setEuro, EURO_NORMAL, EURO_BUSINESS, EURO_IGNORE
translateString
protected String translateString(String str)
- Returns the translation of the native string in the current language.
If the translation could not be found returns "".
- Parameters:
- str - the native string to be translated
translateString
protected abstract String translateString(String str,
String form,
String component)
- Returns the translation of the context sensitive native string in the current language.
If the translation could not be found returns "".
- Parameters:
- str - the native string to be translated
- form - the form context of the string
- component - the component context of the string
doesSupportLocale
protected boolean doesSupportLocale(Locale locale)
- Returns true if the dictionary contains the language that the given locale uses.
- Parameters:
- locale - the locale to be checked
- See Also:
- doesSystemSupportLocale
doesSystemSupportLocale
public static boolean doesSystemSupportLocale(Locale locale)
- Returns true if the system supports the given locale.
- Parameters:
- locale - the locale to be checked
- See Also:
- doesSupportLocale
decodeLocale
protected static Locale decodeLocale(Locale locale)
- Returns the mapped locale
- Parameters:
- locale - the locale to be mapped. If this is "" the default locale of the system is used
localeToLanguage
protected int localeToLanguage(Locale locale)
- Returns the language index that the given locale uses.
Returns -1 if the dictionary does not contain any language supporting the locale.
- Parameters:
- locale - the locale to be used
getDefaultLanguage
protected int getDefaultLanguage()
- Gets the index of the default language.
This is 1 if the first language is the fake language and 0 i any other case.
canBeOpened
protected boolean canBeOpened()
- Returns true if the dictionary can be opened.
open
public void open()
- Opens the dictionary.
- See Also:
- isOpen, close
isOpen
public boolean isOpen()
- Returns true if the dictionary has been opened.
- See Also:
- open
close
public void close()
- Closes the dictionary.
- See Also:
- open
defaultTranslate
public static String defaultTranslate(String str)
- Returns the translations for the given string. Uses the default dictionary.
- Parameters:
- str - the native string to be translated
- See Also:
- getDefaultDictionary, translate
translate
public String translate(String str)
- Returns the translations for the given string.
- Parameters:
- str - the native string to be translated
translate
public String translate(String str,
String form,
String component)
- Returns the translations for the given context sensitive string.
- Parameters:
- str - the native string to be translated
- frame - the form type name part of the context
- component - the component name part of the context
checkTranslation
public String checkTranslation(String str,
String translation)
- Returns the checked translation the given string.
- Parameters:
- str - the native string
- translation - the translation of the native string
setUpdateDefaultLocale
public void setUpdateDefaultLocale(boolean value)
- Sets the update default locale.
If this is true the dictionary updates the default locale to match the active locale.
The default value is true.
getUpdateDefaultLocale
public boolean getUpdateDefaultLocale()
- Gets the update default locale.
isFormContext
public boolean isFormContext()
- Returns true if the dictionary uses the form context.
isComponentContext
public boolean isComponentContext()
- Returns true if the dictionary uses the component context.
isFullContext
public boolean isFullContext()
- Returns true if the dictionary uses the full context.
isNoneContext
public boolean isNoneContext()
- Returns true if the dictionary does not use any context.
setContextCode
public void setContextCode(int value)
- Sets the context code.
- See Also:
- CC_FLAT, CC_FULL, CC_COMPONENT, CC_FORM
setApplet
public void setApplet(Applet value)
- Sets the host applet.
If the dictionary is used in an applet set the applet property to contain the host applet.
- See Also:
- getApplet
getApplet
public Applet getApplet()
- Gets the host applet.
- See Also:
- setApplet
setDictionaryName
public void setDictionaryName(String value)
- Sets the name of the dictionary.
- See Also:
- getDictionaryName
getDictionaryName
public String getDictionaryName()
- Gets the name of the dictionary.
- See Also:
- setDictionaryName
setAutoTranslate
public void setAutoTranslate(boolean value)
- Sets the auto translation. The default value is true.
- See Also:
- getAutoTranslate
getAutoTranslate
public boolean getAutoTranslate()
- Gets the auto translation.
If this is true the dictionary translates every listener after the Language property has been changed.
- See Also:
- setAutoTranslate
setMissingTranslation
public void setMissingTranslation(int value)
- Sets the MissingTranslation property.
- See Also:
- MT_USE_NATIVE, MT_USE_EMPTY, MT_TAG_NATIVE, MT_THROW_EXCEPTION, getMissingTranslation
getMissingTranslation
public int getMissingTranslation()
- Gets the MissingTranslation property.
- See Also:
- MT_USE_NATIVE, MT_USE_EMPTY, MT_TAG_NATIVE, MT_THROW_EXCEPTION, setMissingTranslation
setCheckSupport
public void setCheckSupport(boolean value)
- Sets the language checking. The default value is true.
- See Also:
- getCheckSupport, setCheckLanguage
getCheckSupport
public boolean getCheckSupport()
- Gets the language checking.
If this is true the dictionary check the language to be set active.
- See Also:
- setCheckSupport, getCheckLanguage
setCheckLanguage
public void setCheckLanguage(boolean value)
- Sets the language checking. The default value is true.
- See Also:
- setCheckSupport, getCheckLanguage
getCheckLanguage
public boolean getCheckLanguage()
- Gets the language checking.
If this is true the dictionary check the language to be set active.
- See Also:
- getCheckSupport, setCheckLanguage
setBinding
public void setBinding(int value)
- Sets the locale binding.
If the value is set to true, the locale is set to the default locale of
the current language. The default value is true.
- See Also:
- setLanguage, setLocale
getBinding
public int getBinding()
- Gets the locale binding.
If this is true the language and the locale properties are bound.
- See Also:
- getLanguage, getLocale
setLanguage
public void setLanguage(int value)
- Sets the current language index.
The index of the first language of the dictionary is 0, the second 1, etc.
If the language and locale has been bound this also sets the locale to match the default locale of the new language.
- See Also:
- setLocale, setBindLocale
getLanguage
public int getLanguage()
- Gets the language index.
- See Also:
- getActiveLanguage, getLanguageData, getLocale
getActiveLanguage
public int getActiveLanguage()
- Gets the active language index.
- See Also:
- getLanguage
getLanguageCount
public abstract int getLanguageCount()
- Gets the amount of the languages in the dictionary.
- See Also:
- getLanguageData, getTranslationCount
getLanguageData
public abstract Language getLanguageData(int index)
- Gets the specified language.
- See Also:
- getLanguageCount, getLanguageDatas
getLanguageData
public Language getLanguageData()
- Gets the current language.
- See Also:
- getLanguage
getLanguageDatas
public Language[] getLanguageDatas()
- Gets the all languages.
- See Also:
- getLanguageCount, getLanguageData
getTranslationCount
public int getTranslationCount()
- Returns the translation count.
- See Also:
- getLanguageCount
setLocale
public void setLocale(Locale value)
- Sets the locale of the dictionary.
If the language and locale has been bound this also sets the language to match the new locale.
If this is "" the default locale is used.
- See Also:
- setLanguage, setBindLocale
getLocale
public Locale getLocale()
- Gets the locale of the dictionary.
- See Also:
- getLanguage, getLanguageLocale
getActiveLocale
public Locale getActiveLocale()
- Gets the active locale of the dictionary. The mapped locale is never "".
- See Also:
- getLocale, getLanguageLocale
getLanguageLocale
public Locale getLanguageLocale()
- Gets the locale of the active language of the dictionary.
- See Also:
- getLocale, getActiveLocale
languageChanged
protected void languageChanged(boolean languageChanged,
boolean localeChanged)
- Dictionary calls this method after the current language has been changed.
Delivers the language change event to every dictionary listener.
getDefaultDictionary
public static Dictionary getDefaultDictionary()
- Returns the default dictionary. The default dictionary is the dictionary
that has been created first.
getDictionary
public static Dictionary getDictionary(int index)
- Gets a dictionary by index.
getDictionary
public static Dictionary getDictionary(String name)
- Gets a dictionary by name.
If the dictionary does not exist returns the default dictionary.
- Parameters:
- name - the name of the dictionary
- See Also:
- getDictionaryName, findDictionary
findDictionary
public static Dictionary findDictionary(String name)
- Finds a dictionary by name.
Returns the dictionary or null if the dictionary does not exist.
- Parameters:
- name - the name of the dictionary
- See Also:
- getDictionaryName, getDictionary
addLanguageChangeListener
public synchronized void addLanguageChangeListener(DictionaryListener l)
- Adds the specified language change listener to receive language change events from this dictionary.
- Parameters:
- l - the language change listener
- See Also:
- removeLanguageChangeListener
removeLanguageChangeListener
public synchronized void removeLanguageChangeListener(DictionaryListener l)
- Removes the language change listener so it no longer receives language change events from this dictionary.
- Parameters:
- l - the language change listener
- See Also:
- addLanguageChangeListener
All Packages Class Hierarchy This Package Previous Next Index