com.limegroup.gnutella.settings
Class SettingsFactory

java.lang.Object
  extended bycom.limegroup.gnutella.settings.SettingsFactory

public final class SettingsFactory
extends java.lang.Object

Class for handling all LimeWire settings that are stored to disk. To add a new setting, simply add a new public static member to the list of settings. Each setting constructor takes the name of the key and the default value, and all settings are typed. Choose the correct Setting subclass for your setting type. It is also important to choose a unique string key for your setting name -- otherwise there will be conflicts.


Field Summary
protected  java.util.Properties DEFAULT_PROPS
          Properties instance for the defualt values.
protected  java.util.Properties PROPS
          The Properties instance containing all settings.
 
Method Summary
 void changeFile(java.io.File toUse)
          Changes the backing file to use for this factory.
 BooleanSetting createBooleanSetting(java.lang.String key, boolean defaultValue)
          Creates a new BooleanSetting instance with the specified key and default value.
 ByteSetting createByteSetting(java.lang.String key, byte defaultValue)
          Creates a new ByteSetting instance with the specified key and default value.
 CharArraySetting createCharArraySetting(java.lang.String key, char[] defaultValue)
          Creates a new CharArraySetting instance for a character array setting with the specified key and default value.
 ColorSetting createColorSetting(java.lang.String key, java.awt.Color defaultValue)
          Creates a new ColorSetting instance with the specified key and default value.
 BooleanSetting createExpirableBooleanSetting(java.lang.String key, boolean defaultValue)
          Creates a new expiring BooleanSetting instance with the specified key and default value.
 IntSetting createExpirableIntSetting(java.lang.String key, int defaultValue)
          Creates a new expiring IntSetting instance with the specified key and default value.
 FileArraySetting createFileArraySetting(java.lang.String key, java.io.File[] defaultValue)
          Creates a new FileArraySetting instance for a File array setting with the specified key and default value.
 FileSetting createFileSetting(java.lang.String key, java.io.File defaultValue)
          Creates a new FileSetting instance with the specified key and default value.
 FloatSetting createFloatSetting(java.lang.String key, float defaultValue)
          Creates a new FloatSetting instance with the specified key and default value.
 IntSetting createIntSetting(java.lang.String key, int defaultValue)
          Creates a new IntSetting instance with the specified key and default value.
 LongSetting createLongSetting(java.lang.String key, long defaultValue)
          Creates a new LongSetting instance with the specified key and default value.
 StringArraySetting createStringArraySetting(java.lang.String key, java.lang.String[] defaultValue)
          Creates a new StringArraySetting instance for a String array setting with the specified key and default value.
 StringSetting createStringSetting(java.lang.String key, java.lang.String defaultValue)
          Creates a new StringSetting instance with the specified key and default value.
 java.util.Iterator iterator()
          Returns the iterator over the settings stored in this factory.
 void reload()
          Reloads the settings with the predefined settings file from disk.
 void revertToDefault()
          Reverts all settings to their factory defaults.
 void save()
          Save setting information to property file We want to NOT save any properties which are the default value, as well as any older properties that are no longer in use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROPS

protected final java.util.Properties DEFAULT_PROPS
Properties instance for the defualt values.


PROPS

protected final java.util.Properties PROPS
The Properties instance containing all settings.

Method Detail

iterator

public java.util.Iterator iterator()
Returns the iterator over the settings stored in this factory. LOCKING: The caller must ensure that this factory's monitor is held while iterating over the iterator.


reload

public void reload()
Reloads the settings with the predefined settings file from disk.


changeFile

public void changeFile(java.io.File toUse)
Changes the backing file to use for this factory.


revertToDefault

public void revertToDefault()
Reverts all settings to their factory defaults.


save

public void save()
Save setting information to property file We want to NOT save any properties which are the default value, as well as any older properties that are no longer in use. To avoid having to manually encode the file, we create a new properties object and add to it only the ones we want to save. (Note that we cannot use 'store' since it's only available in 1.2)


createStringSetting

public StringSetting createStringSetting(java.lang.String key,
                                         java.lang.String defaultValue)
Creates a new StringSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createBooleanSetting

public BooleanSetting createBooleanSetting(java.lang.String key,
                                           boolean defaultValue)
Creates a new BooleanSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createIntSetting

public IntSetting createIntSetting(java.lang.String key,
                                   int defaultValue)
Creates a new IntSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createByteSetting

public ByteSetting createByteSetting(java.lang.String key,
                                     byte defaultValue)
Creates a new ByteSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createLongSetting

public LongSetting createLongSetting(java.lang.String key,
                                     long defaultValue)
Creates a new LongSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createFileSetting

public FileSetting createFileSetting(java.lang.String key,
                                     java.io.File defaultValue)
Creates a new FileSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createColorSetting

public ColorSetting createColorSetting(java.lang.String key,
                                       java.awt.Color defaultValue)
Creates a new ColorSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createCharArraySetting

public CharArraySetting createCharArraySetting(java.lang.String key,
                                               char[] defaultValue)
Creates a new CharArraySetting instance for a character array setting with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createFloatSetting

public FloatSetting createFloatSetting(java.lang.String key,
                                       float defaultValue)
Creates a new FloatSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createStringArraySetting

public StringArraySetting createStringArraySetting(java.lang.String key,
                                                   java.lang.String[] defaultValue)
Creates a new StringArraySetting instance for a String array setting with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createFileArraySetting

public FileArraySetting createFileArraySetting(java.lang.String key,
                                               java.io.File[] defaultValue)
Creates a new FileArraySetting instance for a File array setting with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createExpirableBooleanSetting

public BooleanSetting createExpirableBooleanSetting(java.lang.String key,
                                                    boolean defaultValue)
Creates a new expiring BooleanSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting

createExpirableIntSetting

public IntSetting createExpirableIntSetting(java.lang.String key,
                                            int defaultValue)
Creates a new expiring IntSetting instance with the specified key and default value.

Parameters:
key - the key for the setting
defaultValue - the default value for the setting