uk.ac.essex.common.lang
Class MutablePropertyResourceBundle

java.lang.Object
  extended by java.util.ResourceBundle
      extended by uk.ac.essex.common.lang.MutablePropertyResourceBundle

public class MutablePropertyResourceBundle
extends java.util.ResourceBundle

An implmentation of a properties resource bundle that allows users to add hashmaps of resource strings AFTER initialisation. This implmentaion keeps a list of HashMaps as oppose to one big one. This will mean there could be multiple keys which one gets returned depends on the current policy (either FIFO or LIFO) see the method setAsFifo(boolean).


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.ResourceBundle
java.util.ResourceBundle.Control
 
Field Summary
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
MutablePropertyResourceBundle()
           
 
Method Summary
 void addMap(java.util.HashMap hashMapToAdd)
          Add a hash table of resource string to the ones already stored.
 void addPropertyResourceBundle(java.util.PropertyResourceBundle propertyResourceBundle)
           
 java.util.Enumeration getKeys()
          Implementation of ResourceBundle.getKeys.
 java.lang.Object handleGetObject(java.lang.String key)
          Override of PropertyResourceBundle, does exactly the same but also searches any hashmaps that have been added.
 void remove(java.util.HashMap hashMapToRemove)
          Remove a hashmap of translation, since the hash maps added are stored in a list.
 void setAsFifo(boolean isFifo)
          This determines the way property values are returned.
 
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutablePropertyResourceBundle

public MutablePropertyResourceBundle()
Method Detail

addMap

public void addMap(java.util.HashMap hashMapToAdd)
Add a hash table of resource string to the ones already stored. This will preserve all keys read previously and these will have preference over the newer ones.

Throws:
java.lang.NullPointerException - - If hashMapToAdd is null

addPropertyResourceBundle

public void addPropertyResourceBundle(java.util.PropertyResourceBundle propertyResourceBundle)

remove

public void remove(java.util.HashMap hashMapToRemove)
Remove a hashmap of translation, since the hash maps added are stored in a list. This method just simply calls List::remove.


handleGetObject

public java.lang.Object handleGetObject(java.lang.String key)
Override of PropertyResourceBundle, does exactly the same but also searches any hashmaps that have been added. The order these are searched depends on the current policy

Specified by:
handleGetObject in class java.util.ResourceBundle
See Also:
setAsFifo(boolean)

setAsFifo

public void setAsFifo(boolean isFifo)
This determines the way property values are returned. Basically each hashmap of properties is added to a list, when a property is requested then this list is traversed. This means that a property added sooner will be lower in the chain than the same property added in a later hashmap. This means when obtaining properties this class acts similar to a First In First Out (FIFO) manner by default. This method allows you to change that so the list of hashmaps is traversed backwards ie/ a Last In First Out (LIFO) policy.

Parameters:
isFifo -

getKeys

public java.util.Enumeration getKeys()
Implementation of ResourceBundle.getKeys.

Specified by:
getKeys in class java.util.ResourceBundle