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

Variable Index

 o BIND_LANGUAGE_TO_LOCALE
Language is bound to Locale.
 o BIND_LOCALE_TO_LANGUAGE
Locale is bound to Language.
 o BIND_NONE
Language and Locale properties are not noy bound together.
 o CC_COMPONENT
Dictionary uses the component context information.
 o CC_FLAT
Dictionary does not use context information.
 o CC_FORM
Dictionary uses the form context information.
 o CC_FULL
Dictionary uses the full context information.
 o componentContext
True if the dictionary uses the component context.
 o DEFAULT_LANGUAGE
 o dictionaries
A vector that contains all the dictionary components that have been created.
 o EMU_EURO
Only Euro is used.
 o EMU_EURO_AND_NATIONAL
Euro and national currency are both used.
 o EMU_NATIONAL
National currency is used.
 o EMU_NATIONAL_AND_EURO
National currency is used in the every day life.
 o EMU_NONE
Locale is not a EMU member
 o EURO
Euro variant of the Locale class.
 o EURO_BUSINESS
Euro locale variant is used starting on January 1, 1999
 o EURO_IGNORE
Multilizer ignores Euro
 o EURO_NORMAL
Euro locale variant is used starting on January 1, 2002
 o formContext
True if the dictionary uses the form context.
 o MT_TAG_NATIVE
Tag the native string if the translation can not be found.
 o MT_THROW_EXCEPTION
Throw a RuntimeException if the translation can not be found.
 o MT_USE_EMPTY
Use the empty string if the translation can not be found.
 o MT_USE_NATIVE
Use the native string if the translation can not be found.

Constructor Index

 o Dictionary()
Creates a new dictionary.

Method Index

 o addLanguageChangeListener(DictionaryListener)
Adds the specified language change listener to receive language change events from this dictionary.
 o canBeOpened()
Returns true if the dictionary can be opened.
 o checkTranslation(String, String)
Returns the checked translation the given string.
 o close()
Closes the dictionary.
 o decodeLocale(Locale)
Returns the mapped locale
 o defaultTranslate(String)
Returns the translations for the given string.
 o dispose()
Removes the dictionary from the dictionary list and closes the dictionary.
 o doesSupportLocale(Locale)
Returns true if the dictionary contains the language that the given locale uses.
 o doesSystemSupportLocale(Locale)
Returns true if the system supports the given locale.
 o finalize()
Disposes of this dictionary once it is no longer referenced.
 o findDictionary(String)
Finds a dictionary by name.
 o getActiveLanguage()
Gets the active language index.
 o getActiveLocale()
Gets the active locale of the dictionary.
 o getApplet()
Gets the host applet.
 o getAutoTranslate()
Gets the auto translation.
 o getBinding()
Gets the locale binding.
 o getCheckLanguage()
Gets the language checking.
 o getCheckSupport()
Gets the language checking.
 o getDefaultDictionary()
Returns the default dictionary.
 o getDefaultLanguage()
Gets the index of the default language.
 o getDictionary(int)
Gets a dictionary by index.
 o getDictionary(String)
Gets a dictionary by name.
 o getDictionaryName()
Gets the name of the dictionary.
 o getEMUPhase()
Returns the current phase of EMU (Economic and Monetary Union)
 o getEuro()
Gets the Euro usage.
 o getLanguage()
Gets the language index.
 o getLanguageCount()
Gets the amount of the languages in the dictionary.
 o getLanguageData()
Gets the current language.
 o getLanguageData(int)
Gets the specified language.
 o getLanguageDatas()
Gets the all languages.
 o getLanguageLocale()
Gets the locale of the active language of the dictionary.
 o getLocale()
Gets the locale of the dictionary.
 o getMissingTranslation()
Gets the MissingTranslation property.
 o getTranslationCount()
Returns the translation count.
 o getUpdateDefaultLocale()
Gets the update default locale.
 o isComponentContext()
Returns true if the dictionary uses the component context.
 o isEMUMember(Locale)
Returns true if the given locale is a member of EMU (Economic and Monetary Union)
 o isFormContext()
Returns true if the dictionary uses the form context.
 o isFullContext()
Returns true if the dictionary uses the full context.
 o isLanguageBidirectional()
Returns true if the active language is bidirectional (e.g.
 o isLanguageEuropean()
Returns true if the active language is European.
 o isLanguageFarEastern()
Returns true if the active language is Far Eastern.
 o isNoneContext()
Returns true if the dictionary does not use any context.
 o isOpen()
Returns true if the dictionary has been opened.
 o languageChanged(boolean, boolean)
Dictionary calls this method after the current language has been changed.
 o localeToLanguage(Locale)
Returns the language index that the given locale uses.
 o open()
Opens the dictionary.
 o removeLanguageChangeListener(DictionaryListener)
Removes the language change listener so it no longer receives language change events from this dictionary.
 o setApplet(Applet)
Sets the host applet.
 o setAutoTranslate(boolean)
Sets the auto translation.
 o setBinding(int)
Sets the locale binding.
 o setCheckLanguage(boolean)
Sets the language checking.
 o setCheckSupport(boolean)
Sets the language checking.
 o setContextCode(int)
Sets the context code.
 o setDictionaryName(String)
Sets the name of the dictionary.
 o setEuro(int)
Sets the Euro usage.
 o setLanguage(int)
Sets the current language index.
 o setLocale(Locale)
Sets the locale of the dictionary.
 o setMissingTranslation(int)
Sets the MissingTranslation property.
 o setUpdateDefaultLocale(boolean)
Sets the update default locale.
 o translate(String)
Returns the translations for the given string.
 o translate(String, String, String)
Returns the translations for the given context sensitive string.
 o translateString(String)
Returns the translation of the native string in the current language.
 o translateString(String, String, String)
Returns the translation of the context sensitive native string in the current language.

Variables

 o DEFAULT_LANGUAGE
 public static final int DEFAULT_LANGUAGE
 o CC_FLAT
 public static final int CC_FLAT
Dictionary does not use context information. Each string is identified by its native value.

 o 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.

 o 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.

 o 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.

 o BIND_NONE
 public static final int BIND_NONE
Language and Locale properties are not noy bound together.

 o 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.

 o 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.

 o EURO
 public static final String EURO
Euro variant of the Locale class.

 o EURO_NORMAL
 public static final int EURO_NORMAL
Euro locale variant is used starting on January 1, 2002

 o EURO_BUSINESS
 public static final int EURO_BUSINESS
Euro locale variant is used starting on January 1, 1999

 o EURO_IGNORE
 public static final int EURO_IGNORE
Multilizer ignores Euro

 o EMU_NONE
 public static final int EMU_NONE
Locale is not a EMU member

 o EMU_NATIONAL
 public static final int EMU_NATIONAL
National currency is used. Date is before January 1, 1999

 o 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.

 o 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.

 o EMU_EURO
 public static final int EMU_EURO
Only Euro is used. Date is July 1, 2002 or later.

 o 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
 o 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
 o 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
 o 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
 o formContext
 protected transient boolean formContext
True if the dictionary uses the form context.

 o componentContext
 protected transient boolean componentContext
True if the dictionary uses the component context.

 o dictionaries
 public static Vector dictionaries
A vector that contains all the dictionary components that have been created.

Constructors

 o Dictionary
 public Dictionary()
Creates a new dictionary.

Methods

 o finalize
 protected void finalize()
Disposes of this dictionary once it is no longer referenced.

Overrides:
finalize in class Object
 o dispose
 public void dispose()
Removes the dictionary from the dictionary list and closes the dictionary.

 o isLanguageEuropean
 public boolean isLanguageEuropean()
Returns true if the active language is European.

 o isLanguageBidirectional
 public boolean isLanguageBidirectional()
Returns true if the active language is bidirectional (e.g. Arabic or Hebrew).

 o isLanguageFarEastern
 public boolean isLanguageFarEastern()
Returns true if the active language is Far Eastern.

 o 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
 o 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
 o setEuro
 public void setEuro(int value)
Sets the Euro usage.

See Also:
getEuro, EURO_NORMAL, EURO_BUSINESS, EURO_IGNORE
 o getEuro
 public int getEuro()
Gets the Euro usage.

See Also:
setEuro, EURO_NORMAL, EURO_BUSINESS, EURO_IGNORE
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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.

 o canBeOpened
 protected boolean canBeOpened()
Returns true if the dictionary can be opened.

 o open
 public void open()
Opens the dictionary.

See Also:
isOpen, close
 o isOpen
 public boolean isOpen()
Returns true if the dictionary has been opened.

See Also:
open
 o close
 public void close()
Closes the dictionary.

See Also:
open
 o 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
 o translate
 public String translate(String str)
Returns the translations for the given string.

Parameters:
str - the native string to be translated
 o 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
 o 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
 o 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.

 o getUpdateDefaultLocale
 public boolean getUpdateDefaultLocale()
Gets the update default locale.

 o isFormContext
 public boolean isFormContext()
Returns true if the dictionary uses the form context.

 o isComponentContext
 public boolean isComponentContext()
Returns true if the dictionary uses the component context.

 o isFullContext
 public boolean isFullContext()
Returns true if the dictionary uses the full context.

 o isNoneContext
 public boolean isNoneContext()
Returns true if the dictionary does not use any context.

 o setContextCode
 public void setContextCode(int value)
Sets the context code.

See Also:
CC_FLAT, CC_FULL, CC_COMPONENT, CC_FORM
 o 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
 o getApplet
 public Applet getApplet()
Gets the host applet.

See Also:
setApplet
 o setDictionaryName
 public void setDictionaryName(String value)
Sets the name of the dictionary.

See Also:
getDictionaryName
 o getDictionaryName
 public String getDictionaryName()
Gets the name of the dictionary.

See Also:
setDictionaryName
 o setAutoTranslate
 public void setAutoTranslate(boolean value)
Sets the auto translation. The default value is true.

See Also:
getAutoTranslate
 o 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
 o 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
 o getMissingTranslation
 public int getMissingTranslation()
Gets the MissingTranslation property.

See Also:
MT_USE_NATIVE, MT_USE_EMPTY, MT_TAG_NATIVE, MT_THROW_EXCEPTION, setMissingTranslation
 o setCheckSupport
 public void setCheckSupport(boolean value)
Sets the language checking. The default value is true.

See Also:
getCheckSupport, setCheckLanguage
 o 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
 o setCheckLanguage
 public void setCheckLanguage(boolean value)
Sets the language checking. The default value is true.

See Also:
setCheckSupport, getCheckLanguage
 o 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
 o 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
 o getBinding
 public int getBinding()
Gets the locale binding. If this is true the language and the locale properties are bound.

See Also:
getLanguage, getLocale
 o 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
 o getLanguage
 public int getLanguage()
Gets the language index.

See Also:
getActiveLanguage, getLanguageData, getLocale
 o getActiveLanguage
 public int getActiveLanguage()
Gets the active language index.

See Also:
getLanguage
 o getLanguageCount
 public abstract int getLanguageCount()
Gets the amount of the languages in the dictionary.

See Also:
getLanguageData, getTranslationCount
 o getLanguageData
 public abstract Language getLanguageData(int index)
Gets the specified language.

See Also:
getLanguageCount, getLanguageDatas
 o getLanguageData
 public Language getLanguageData()
Gets the current language.

See Also:
getLanguage
 o getLanguageDatas
 public Language[] getLanguageDatas()
Gets the all languages.

See Also:
getLanguageCount, getLanguageData
 o getTranslationCount
 public int getTranslationCount()
Returns the translation count.

See Also:
getLanguageCount
 o 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
 o getLocale
 public Locale getLocale()
Gets the locale of the dictionary.

See Also:
getLanguage, getLanguageLocale
 o getActiveLocale
 public Locale getActiveLocale()
Gets the active locale of the dictionary. The mapped locale is never "".

See Also:
getLocale, getLanguageLocale
 o getLanguageLocale
 public Locale getLanguageLocale()
Gets the locale of the active language of the dictionary.

See Also:
getLocale, getActiveLocale
 o 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.

 o getDefaultDictionary
 public static Dictionary getDefaultDictionary()
Returns the default dictionary. The default dictionary is the dictionary that has been created first.

 o getDictionary
 public static Dictionary getDictionary(int index)
Gets a dictionary by index.

 o 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
 o 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
 o 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
 o 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