org.openbandy.service
Class PreferencesService

java.lang.Object
  extended by org.openbandy.service.Service
      extended by org.openbandy.service.PreferencesService

public class PreferencesService
extends Service

This is a helper class to simplify (and abstract) the usage of the preference class by providing static methods. Note: Unlike as within the Preferences class itself, we are allowed to use the LogService here, as the Log itself does not use the PreferencesService but rather Preferences directly.

(c) Copyright Philipp Bolliger 2008, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)
See Also:
Preferences

Constructor Summary
PreferencesService()
           
 
Method Summary
static void add(java.lang.String name, boolean screenModifiable)
          Add a new preference to the persistent store with the given name.
static boolean getBooleanValue(java.lang.String name)
          Reads the boolean preference with the given name from the persistent store.
static int getIntValue(java.lang.String name)
          Reads the int preference with the given name from the persistent store.
static java.lang.String getValue(java.lang.String name)
          Reads the String preference with the given name from the persistent store.
static void remove(java.lang.String name)
          Remove the preference with the given name from the persistent store.
static void setBooleanValue(java.lang.String name, boolean value)
          Set the value of the preference that is identified with the given name string to the given value.
static void setIntValue(java.lang.String name, int value)
          Set the value of the preference that is identified with the given name string to the given value.
static void setValue(java.lang.String name, java.lang.String value)
          Set the value of the preference that is identified with the given name string to the given value.
 
Methods inherited from class org.openbandy.service.Service
runningOnMicroEdition, runningOnSunWTK
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesService

public PreferencesService()
Method Detail

add

public static void add(java.lang.String name,
                       boolean screenModifiable)
Add a new preference to the persistent store with the given name. Make sure that you use a unique string.

Parameters:
name - The (unique) string used to identify the preference.
screenModifiable - screenModifiable if true, the preference will appear in the preferences form screen

remove

public static void remove(java.lang.String name)
Remove the preference with the given name from the persistent store.

Parameters:
name - The (unique) string used to identify the preference.

getValue

public static java.lang.String getValue(java.lang.String name)
Reads the String preference with the given name from the persistent store.

Parameters:
name - The (unique) name description of the stored preference value
Returns:
The stored value or the empty string if no string value is stored with the given name

getIntValue

public static int getIntValue(java.lang.String name)
Reads the int preference with the given name from the persistent store.

Parameters:
name - The (unique) name description of the stored preference value
Returns:
The stored value or 0 if no int value is stored with the given name

getBooleanValue

public static boolean getBooleanValue(java.lang.String name)
Reads the boolean preference with the given name from the persistent store.

Parameters:
name - The (unique) name description of the stored preference value
Returns:
The stored value or false if no boolean value is stored with the given name

setValue

public static void setValue(java.lang.String name,
                            java.lang.String value)
Set the value of the preference that is identified with the given name string to the given value. If the preference does not already exist, it will be added, however as not screen modifiable.

Parameters:
name - The (unique) name description of the stored preference value
value - The value to be set

setIntValue

public static void setIntValue(java.lang.String name,
                               int value)
Set the value of the preference that is identified with the given name string to the given value. If the preference does not already exist, it will be added, however as not screen modifiable.

Parameters:
name - The (unique) name description of the stored preference value
value - The int value to be set

setBooleanValue

public static void setBooleanValue(java.lang.String name,
                                   boolean value)
Set the value of the preference that is identified with the given name string to the given value. If the preference does not already exist, it will be added, however as not screen modifiable.

Parameters:
name - The (unique) name description of the stored preference value
value - The boolean value to be set