com.horstmann.violet.framework
Class PreferencesService

java.lang.Object
  extended by com.horstmann.violet.framework.PreferencesService

public abstract class PreferencesService
extends java.lang.Object

A service for storing and loading user preferences. This service uses either the standard Java preferences API or the WebStart persistence service ("muffins").


Constructor Summary
PreferencesService()
           
 
Method Summary
abstract  java.lang.String get(java.lang.String key, java.lang.String defval)
          Gets a previously stored string from the service.
static PreferencesService getInstance(java.lang.Class appClass)
          Gets an instance of the service, suitable for the package of the given class.
abstract  void put(java.lang.String key, java.lang.String value)
          Saves a key/value pair for later retrieval.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesService

public PreferencesService()
Method Detail

getInstance

public static PreferencesService getInstance(java.lang.Class appClass)
Gets an instance of the service, suitable for the package of the given class.

Parameters:
appClass - the main application class (only the package name is used as the path to app-specific preferences storage)
Returns:
an instance of the service

get

public abstract java.lang.String get(java.lang.String key,
                                     java.lang.String defval)
Gets a previously stored string from the service.

Parameters:
key - the key of the string
defval - the value to return if no matching value was found
Returns:
the value stored with the given key, or defval if none was found

put

public abstract void put(java.lang.String key,
                         java.lang.String value)
Saves a key/value pair for later retrieval.

Parameters:
key - the key of the string to be stored
value - the value to to be stored