Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.gatherer
Class Dictionary  view Dictionary download Dictionary.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.greenstone.gatherer.Dictionary
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class Dictionary
extends java.util.HashMap

Extends the ResourceBundle class to allow for the automatic insertion of arguments. Note that the key names beginning Farg are reserved for formatting.

Property files usable by this class have the Backus-Naur form:

FileLine ::= Comment | Mapping
Comment ::= '#' SString
Mapping ::= NZString ':' SString ( Argument SString )*
NZString ::= ( Char | Int ) SString
Argument ::= '{' Int '}'
SString ::= String . ['"','#',...] -> ['\"','\#',...]

In order to add a new dictionary Locale, simply copy the existing dictionary.properties files, replace the values (Strings after the ':') with the new language specific ones being careful to maintain formatting and Gatherer placed arguments, then save the new dictionary as:

dictionary_locale.properties

where locale is made of two two-letter codes seperated by an underscore. The first code is in lower-case and defines the language. The second is in upper-case and defines the country. For example the default dictionary could also correctly be called:
dictionary_en_NZ.properties

Version:
2.3

Nested Class Summary
private static class Dictionary.ComponentDetails
           
private static class Dictionary.ComponentUpdateTask
           
private static class Dictionary.JTabbedPaneChangeTask
          Updates a tabbed panes tab title and tooltip.
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private  java.util.ResourceBundle dictionary
          The ResourceBundle which contains the raw key-value mappings.
private  javax.swing.plaf.FontUIResource font
          The font used when displaying various html text.
private  java.util.TreeSet key_list
           
private static boolean KEY_LIST_DEBUG
           
private static java.lang.String KEY_LIST_FILENAME
           
 java.lang.String language
          A String which more explicitly states the Locale of this dictionary.
private  java.util.Locale locale
          A reference to remind us of the current locale.
static Dictionary self
          A static reference to ourself.
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
Dictionary(java.util.Locale locale, javax.swing.plaf.FontUIResource font)
          Constructs the Dictionary class by first checking if a Locale has been set.
 
Method Summary
 void changeDictionary(java.util.Locale locale)
          Change the currently loaded dictionary and update registered components
 void destroy()
          Remove the component from our registered components list.
static java.lang.String get(java.lang.String key)
           
static java.lang.String get(java.lang.String key, java.lang.String arg)
           
static java.lang.String get(java.lang.String key, java.lang.String[] args)
           
 java.lang.String getLanguage()
          Retrieve the two letter code of the current language we are using, according to the stored locale.
 java.lang.String oldget(java.lang.String key)
          Deprecated. Overloaded to call get with both a key and an empty argument array.
 java.lang.String oldget(java.lang.String key, java.lang.String arg)
          Deprecated. Convienence method with transforms the second string argument into a string array.
 java.lang.String oldget(java.lang.String key, java.lang.String[] args)
          Used to retrieve a property value from the Locale specific ResourceBundle, based upon the key and arguments supplied.
static void register(javax.swing.JTabbedPane component)
          Register a tab pane component.
static void registerBoth(java.awt.Component component, java.lang.String text_key, java.lang.String tooltip_key)
           
static void registerText(java.awt.Component component, java.lang.String text_key)
           
static void registerText(java.awt.Component component, java.lang.String text_key, java.lang.String[] args)
           
static void registerTooltip(java.awt.Component component, java.lang.String tooltip_key)
           
static void registerTooltip(java.awt.Component component, java.lang.String tooltip_key, boolean is_key)
           
static void setBoth(java.awt.Component component, java.lang.String text_key, java.lang.String tooltip_key)
           
static void setText(java.awt.Component component, java.lang.String text_key)
           
static void setText(java.awt.Component component, java.lang.String text_key, java.lang.String[] args)
           
static void setTooltip(java.awt.Component component, java.lang.String tooltip_key)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
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

KEY_LIST_DEBUG

private static final boolean KEY_LIST_DEBUG
See Also:
Constant Field Values

KEY_LIST_FILENAME

private static final java.lang.String KEY_LIST_FILENAME
See Also:
Constant Field Values

language

public java.lang.String language
A String which more explicitly states the Locale of this dictionary.


self

public static Dictionary self
A static reference to ourself.


font

private javax.swing.plaf.FontUIResource font
The font used when displaying various html text.


locale

private java.util.Locale locale
A reference to remind us of the current locale.


dictionary

private java.util.ResourceBundle dictionary
The ResourceBundle which contains the raw key-value mappings. Loaded from a file named "dictionarylocale.properties


key_list

private java.util.TreeSet key_list
Constructor Detail

Dictionary

public Dictionary(java.util.Locale locale,
                  javax.swing.plaf.FontUIResource font)
Constructs the Dictionary class by first checking if a Locale has been set. If not the default locale is used, and a ResourceBundle is created. Finally a single important String, Language, is made available outside the class so a more read-able version of the Locale of this Dictionary is present.

Method Detail

changeDictionary

public void changeDictionary(java.util.Locale locale)
Change the currently loaded dictionary and update registered components


destroy

public void destroy()
Remove the component from our registered components list.


get

public static java.lang.String get(java.lang.String key)

get

public static java.lang.String get(java.lang.String key,
                                   java.lang.String arg)

get

public static java.lang.String get(java.lang.String key,
                                   java.lang.String[] args)

oldget

public java.lang.String oldget(java.lang.String key)
Deprecated. Overloaded to call get with both a key and an empty argument array.


oldget

public java.lang.String oldget(java.lang.String key,
                               java.lang.String arg)
Deprecated. Convienence method with transforms the second string argument into a string array.


oldget

public java.lang.String oldget(java.lang.String key,
                               java.lang.String[] args)
Used to retrieve a property value from the Locale specific ResourceBundle, based upon the key and arguments supplied. If the key cannot be found or if some other part of the call fails a default (English) error message is returned.
Here the get recieves a second argument which is an array of Strings used to populate argument fields, denoted {n}, within the value String returned. Note that argument numbers greater than or equal to 32 are automatically mapped to the formatting String named Fargn.


getLanguage

public java.lang.String getLanguage()
Retrieve the two letter code of the current language we are using, according to the stored locale.


setBoth

public static void setBoth(java.awt.Component component,
                           java.lang.String text_key,
                           java.lang.String tooltip_key)

setText

public static void setText(java.awt.Component component,
                           java.lang.String text_key)

setText

public static void setText(java.awt.Component component,
                           java.lang.String text_key,
                           java.lang.String[] args)

setTooltip

public static void setTooltip(java.awt.Component component,
                              java.lang.String tooltip_key)

registerBoth

public static void registerBoth(java.awt.Component component,
                                java.lang.String text_key,
                                java.lang.String tooltip_key)

registerText

public static void registerText(java.awt.Component component,
                                java.lang.String text_key)

registerText

public static void registerText(java.awt.Component component,
                                java.lang.String text_key,
                                java.lang.String[] args)

registerTooltip

public static void registerTooltip(java.awt.Component component,
                                   java.lang.String tooltip_key)

registerTooltip

public static void registerTooltip(java.awt.Component component,
                                   java.lang.String tooltip_key,
                                   boolean is_key)

register

public static void register(javax.swing.JTabbedPane component)
Register a tab pane component. This will be deprecated eventually.