net.sf.doolin.gui.util
Class PreferencesUtils

java.lang.Object
  extended by net.sf.doolin.gui.util.PreferencesUtils

public class PreferencesUtils
extends Object

Utility methods for the GUIPreferences that extends the number of types that can be stored and retrieved.

Author:
Damien Coraboeuf

Method Summary
static BigDecimal getBigDecimal(GUIPreferences preferences, String key, BigDecimal defaultValue)
          Retrieves a BigDecimal from the preferences.
static Color getColor(GUIPreferences preferences, String key, Color defaultColor)
          Retrieves a Color from the preferences.
static
<E extends Enum<E>>
E
getEnum(GUIPreferences preferences, String prefKey, Class<E> eClass, E defaultValue)
          Retrieves a Enum from the preferences.
static Font getFont(GUIPreferences preferences, String key, Font defaultFont)
          Retrieves a Font from the preferences.
static
<T extends Serializable>
T
getObject(GUIPreferences preferences, String key)
          Retrieves a Serializable object from the preferences.
static Collection<String> getStringArray(GUIPreferences preferences, String key)
          Retrieves a collection of strings from the preferences.
static void setBigDecimal(GUIPreferences preferences, String key, BigDecimal value)
          Stores a BigDecimal in the preferences
static void setColor(GUIPreferences preferences, String key, Color color)
          Stores a Color in the preferences
static
<E extends Enum<E>>
void
setEnum(GUIPreferences preferences, String prefKey, Enum<E> e)
          Stores a Enum in the preferences
static void setFont(GUIPreferences preferences, String key, Font font)
          Stores a Font in the preferences
static void setObject(GUIPreferences preferences, String key, Serializable object)
          Stores a Serializable object in the preferences
static void setStringArray(GUIPreferences preferences, String key, Collection<String> strings)
          Stores a collection of strings in the preferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBigDecimal

public static BigDecimal getBigDecimal(GUIPreferences preferences,
                                       String key,
                                       BigDecimal defaultValue)
Retrieves a BigDecimal from the preferences.

Parameters:
preferences - Preferences
key - Key
defaultValue - Default value if not found
Returns:
Stored BigDecimal or the default value

getColor

public static Color getColor(GUIPreferences preferences,
                             String key,
                             Color defaultColor)
Retrieves a Color from the preferences.

Parameters:
preferences - Preferences
key - Key
defaultColor - Default value if not found
Returns:
Stored Color or the default value
See Also:
ColorEditor.parseColor(String)

getEnum

public static <E extends Enum<E>> E getEnum(GUIPreferences preferences,
                                            String prefKey,
                                            Class<E> eClass,
                                            E defaultValue)
Retrieves a Enum from the preferences.

Type Parameters:
E - Type of the enumeration
Parameters:
preferences - Preferences
prefKey - Key
eClass - Class of the enumeration
defaultValue - Default value if not found
Returns:
Stored BigDecimal or the default value

getFont

public static Font getFont(GUIPreferences preferences,
                           String key,
                           Font defaultFont)
Retrieves a Font from the preferences.

Parameters:
preferences - Preferences
key - Key
defaultFont - Default value if not found
Returns:
Stored Font or the default value

getObject

public static <T extends Serializable> T getObject(GUIPreferences preferences,
                                                   String key)
Retrieves a Serializable object from the preferences.

Type Parameters:
T - Type of the Serializable object
Parameters:
preferences - Preferences
key - Key
Returns:
Stored BigDecimal or null

getStringArray

public static Collection<String> getStringArray(GUIPreferences preferences,
                                                String key)
Retrieves a collection of strings from the preferences.

Parameters:
preferences - Preferences
key - Key
Returns:
Stored collection or empty array

setBigDecimal

public static void setBigDecimal(GUIPreferences preferences,
                                 String key,
                                 BigDecimal value)
Stores a BigDecimal in the preferences

Parameters:
preferences - Preferences
key - Key
value - Value to store

setColor

public static void setColor(GUIPreferences preferences,
                            String key,
                            Color color)
Stores a Color in the preferences

Parameters:
preferences - Preferences
key - Key
color - Value to store

setEnum

public static <E extends Enum<E>> void setEnum(GUIPreferences preferences,
                                               String prefKey,
                                               Enum<E> e)
Stores a Enum in the preferences

Type Parameters:
E - Type of the enumeration
Parameters:
preferences - Preferences
prefKey - Key
e - Value to store

setFont

public static void setFont(GUIPreferences preferences,
                           String key,
                           Font font)
Stores a Font in the preferences

Parameters:
preferences - Preferences
key - Key
font - Value to store

setObject

public static void setObject(GUIPreferences preferences,
                             String key,
                             Serializable object)
Stores a Serializable object in the preferences

Parameters:
preferences - Preferences
key - Key
object - Value to store

setStringArray

public static void setStringArray(GUIPreferences preferences,
                                  String key,
                                  Collection<String> strings)
Stores a collection of strings in the preferences

Parameters:
preferences - Preferences
key - Key
strings - Values to store


Copyright © 2011. All Rights Reserved.