net.sf.locale4j.storage
Class HashMapStore

java.lang.Object
  extended by net.sf.locale4j.storage.HashMapStore
All Implemented Interfaces:
LocaleStore

public class HashMapStore
extends Object
implements LocaleStore

In memory storage of locale data using HashTables.


Constructor Summary
HashMapStore()
          Default Constructor.
 
Method Summary
 void addLocale(Locale locale)
          Adds the specified locale to the store without any key/value pairs.
 String get(Locale locale, String key)
          Fetches a string in the language specified by the locale.
 List<String> getKeys(Locale locale)
          Fetch a list of keys for the given locale.
 List<Locale> getLocales()
          Fetch a list of locales for which translations exist.
 HashMap<String,HashMap<String,String>> getTable()
           
 void put(Locale locale, String key, String text)
          Stores a string in the language specified by the locale.
 Object removeKey(Locale locale, String key)
          Removes a string from the language specified by the locale.
 Object removeLocale(Locale locale)
          Removes an entire locale.
 void setTable(HashMap<String,HashMap<String,String>> newTable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapStore

public HashMapStore()
Default Constructor.

Method Detail

getTable

public final HashMap<String,HashMap<String,String>> getTable()
Returns:
the table

setTable

public final void setTable(HashMap<String,HashMap<String,String>> newTable)
Parameters:
newTable - the table to set

get

public String get(Locale locale,
                  String key)
Fetches a string in the language specified by the locale. If the string does not exist, "???" is returned.

Specified by:
get in interface LocaleStore
Parameters:
locale - the locale for which the String is localized.
key - the key used to reference the stored String.
Returns:
the localized string.

put

public void put(Locale locale,
                String key,
                String text)
Stores a string in the language specified by the locale.

Specified by:
put in interface LocaleStore
Parameters:
locale - the locale for which the String is localized.
key - the key used to reference the stored String.
text - the String to store.

addLocale

public void addLocale(Locale locale)
Adds the specified locale to the store without any key/value pairs.

Specified by:
addLocale in interface LocaleStore
Parameters:
locale -

getLocales

public List<Locale> getLocales()
Fetch a list of locales for which translations exist.

Specified by:
getLocales in interface LocaleStore
Returns:
a list of locales.

getKeys

public List<String> getKeys(Locale locale)
Fetch a list of keys for the given locale.

Specified by:
getKeys in interface LocaleStore
Parameters:
locale - the locale of the Strings the keys point to.
Returns:
a list of keys

removeKey

public Object removeKey(Locale locale,
                        String key)
                 throws Exception
Removes a string from the language specified by the locale.

Specified by:
removeKey in interface LocaleStore
Parameters:
locale - the locale for which the String is localized.
key - the key used to reference the stored String.
Returns:
the values associated with the removed key, or null if the key/table doesn't exist or is set to null.
Throws:
Exception

removeLocale

public Object removeLocale(Locale locale)
                    throws Exception
Removes an entire locale.

Specified by:
removeLocale in interface LocaleStore
Parameters:
locale - the locale to remove.
Returns:
the values associated with the removed key, or null if the key/table doesn't exist or is set to null.
Throws:
Exception


Copyright © 2007-2008 Vermont Department of Taxes. All Rights Reserved.