src/java/isac/util/usersettings/UserSettings.java
author wneuper
Wed, 15 Jun 2005 18:31:02 +0200
branchjava_rename_format
changeset 3922 fcd5648113ca
permissions -rw-r--r--
java: isac.util.tactics .. end renamed, formatted, inst_var_, import cleaned
     1 /*
     2  * Created on Feb 22, 2005
     3  *
     4  * @author Alan Krempler
     5  */
     6 
     7 package isac.util.usersettings;
     8 
     9 import java.io.Serializable;
    10 import java.util.HashMap;
    11 
    12 /**
    13  * Class for storing/retrieving user settings, i.e. settings which can be set
    14  * manually by the user as opposed to the
    15  * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the
    16  * system's expeience with a user and canot be altered manually. As there is no
    17  * fixed set of user settings, you can regard this class as a simple storage
    18  * backend for key/value pairs.
    19  * 
    20  * @author Alan Krempler
    21  *  
    22  */
    23 public class UserSettings implements Serializable {
    24 
    25     private HashMap storage_;
    26 
    27     UserSettings() {
    28         storage_ = new HashMap();
    29     }
    30 
    31     /**
    32      * @param key
    33      *            A string key
    34      * @return The string value associated with the key parameter; null, if
    35      *         nothing is stored under this key
    36      */
    37     public String getValue(String key) {
    38         return (String) storage_.get(key);
    39     }
    40 
    41     /**
    42      * @param key
    43      *            The key under which "value" is to be stored. Existing data
    44      *            unde the same key will be replaced.
    45      * @param value
    46      *            The value to be stored under "key"
    47      * @return true in case of success, false in case of error, for example if
    48      *         trying to replace stored values without proper permissions
    49      */
    50     public boolean setValue(String key, String value) {
    51         storage_.put(key, value);
    52         return true;
    53     }
    54 
    55 }