src/java/isac/util/usersettings/UserSettings.java
branchjava_rename_format
changeset 3922 fcd5648113ca
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java/isac/util/usersettings/UserSettings.java	Wed Jun 15 18:31:02 2005 +0200
     1.3 @@ -0,0 +1,55 @@
     1.4 +/*
     1.5 + * Created on Feb 22, 2005
     1.6 + *
     1.7 + * @author Alan Krempler
     1.8 + */
     1.9 +
    1.10 +package isac.util.usersettings;
    1.11 +
    1.12 +import java.io.Serializable;
    1.13 +import java.util.HashMap;
    1.14 +
    1.15 +/**
    1.16 + * Class for storing/retrieving user settings, i.e. settings which can be set
    1.17 + * manually by the user as opposed to the
    1.18 + * {@link isac.util.usersettings.UserModel#}, which is an abstraction of the
    1.19 + * system's expeience with a user and canot be altered manually. As there is no
    1.20 + * fixed set of user settings, you can regard this class as a simple storage
    1.21 + * backend for key/value pairs.
    1.22 + * 
    1.23 + * @author Alan Krempler
    1.24 + *  
    1.25 + */
    1.26 +public class UserSettings implements Serializable {
    1.27 +
    1.28 +    private HashMap storage_;
    1.29 +
    1.30 +    UserSettings() {
    1.31 +        storage_ = new HashMap();
    1.32 +    }
    1.33 +
    1.34 +    /**
    1.35 +     * @param key
    1.36 +     *            A string key
    1.37 +     * @return The string value associated with the key parameter; null, if
    1.38 +     *         nothing is stored under this key
    1.39 +     */
    1.40 +    public String getValue(String key) {
    1.41 +        return (String) storage_.get(key);
    1.42 +    }
    1.43 +
    1.44 +    /**
    1.45 +     * @param key
    1.46 +     *            The key under which "value" is to be stored. Existing data
    1.47 +     *            unde the same key will be replaced.
    1.48 +     * @param value
    1.49 +     *            The value to be stored under "key"
    1.50 +     * @return true in case of success, false in case of error, for example if
    1.51 +     *         trying to replace stored values without proper permissions
    1.52 +     */
    1.53 +    public boolean setValue(String key, String value) {
    1.54 +        storage_.put(key, value);
    1.55 +        return true;
    1.56 +    }
    1.57 +
    1.58 +}
    1.59 \ No newline at end of file