com.bigzip
Class Settings

java.lang.Object
  |
  +--com.bigzip.Settings
All Implemented Interfaces:
java.io.Serializable

public final class Settings
extends java.lang.Object
implements java.io.Serializable

A individual Settings object is passed to each plugin. A plugin can use this object to store information that needs to be user preferences for the plugin. The Settings object will be serialized/deserialized between BiGZiP sessions.

A plugin can also create a hierarchy of settings using the createChild and getChild methods. Each child is given an id which is used to access the child. Several Settings objects may have a child with the same id but that id refers to different instances of the Settings object. Because each plugin receives its own Settings object, there is not need for concern about name conflicts between the installed plugins.

A plugin can provide a settings customizer to allow the user to customize its settings. A plugin uses the setSettingsCustomizer to associate a customizer with the Settings object. The settings customizer is responsible for providing the user with access to customize any child Settings objects.

See Also:
Serialized Form

Constructor Summary
Settings()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Registers a PropertyChangeListener with this Settings object.
 Settings createChild(java.lang.String childID)
          Creates a child Settings object under this settings object in the settings hierarchy.
 void deleteAllChildren()
          Deletes all the child Settings objects under this Settings object.
 void deleteChild(java.lang.String childID)
          Deletes the child with the specified id from this Settings object.
 Settings getChild(java.lang.String childID)
          Returns the settings object for this child with the given id.
 SettingsCustomizer getCustomizer()
          Returns the settings customizer UI component that the preferences dialog box can display to allow the user to customize this settings object.
 java.lang.String getSetting(java.lang.String settingName)
          Retrieve the setting with the given name from this Settings object.
 java.lang.String getSetting(java.lang.String name, java.lang.String defaultValue)
          Retrieve the setting with the given name from this Settings object.
 boolean getSettingAsBoolean(java.lang.String name, boolean defaultValue)
          Retrieves a boolean setting with the given name from this Settings object.
 byte getSettingAsByte(java.lang.String name, byte defaultValue)
          Retrieves a byte-sized setting with the given name from this Settings object.
 char getSettingAsCharacter(java.lang.String name, char defaultValue)
          Retrieves a char-sized setting with the given name from this Settings object.
 double getSettingAsDouble(java.lang.String name, double defaultValue)
          Retrieves a double-sized setting with the given name from this Settings object.
 float getSettingAsFloat(java.lang.String name, float defaultValue)
          Retrieves a float-sized setting with the given name from this Settings object.
 int getSettingAsInt(java.lang.String name, int defaultValue)
          Retrieves an int-sized setting with the given name from this Settings object.
 long getSettingAsLong(java.lang.String name, long defaultValue)
          Retrieves a long-sized setting with the given name from this Settings object.
 short getSettingAsShort(java.lang.String name, short defaultValue)
          Retrieves a short-sized setting with the given name from this Settings object.
 boolean hasChild(java.lang.String childID)
          Tests if a child with the given childId exists in this Settings object.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Unregisters a listener from this Settings object.
 void setCustomizer(SettingsCustomizer customizer)
          Associate a settings customizer with this Settings obeject.
 void setSetting(java.lang.String settingName, java.lang.String settingValue)
          Sets a setting with the given name in this Settings object.
 void setSettingAsBoolean(java.lang.String name, boolean value)
          Sets a boolean-sized setting with the given name in this Settings object.
 void setSettingAsByte(java.lang.String name, byte value)
          Sets a byte-sized setting with the given name in this Settings object.
 void setSettingAsCharacter(java.lang.String name, char value)
          Sets a char-sized setting with the given name in this Settings object.
 void setSettingAsDouble(java.lang.String name, double value)
          Sets a double-sized setting with the given name in this Settings object.
 void setSettingAsFloat(java.lang.String name, float value)
          Sets a float-sized setting with the given name in this Settings object.
 void setSettingAsInt(java.lang.String name, int value)
          Sets an int-sized setting with the given name in this Settings object.
 void setSettingAsLong(java.lang.String name, long value)
          Sets a long-sized setting with the given name in this Settings object.
 void setSettingAsShort(java.lang.String name, short value)
          Sets a short-sized setting with the given name in this Settings object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Settings

public Settings()
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Registers a PropertyChangeListener with this Settings object. When a setting is changed, the registers listeners will be notified. This does not include changes in any child settings.
Parameters:
listener - The listener to be registered.

createChild

public Settings createChild(java.lang.String childID)
Creates a child Settings object under this settings object in the settings hierarchy. If a child with the specified childID already exists, it will be replaced with a new, empty settings object.

Normally, one would use the getChild method which will automatically create a new child if it doesn't exist.

Parameters:
childID - The id for the new child which can be used in the future to access it.
Returns:
The new child Settings object.

deleteAllChildren

public void deleteAllChildren()
Deletes all the child Settings objects under this Settings object. If any of the children have children, their children will also be deleted.

deleteChild

public void deleteChild(java.lang.String childID)
Deletes the child with the specified id from this Settings object.

getChild

public Settings getChild(java.lang.String childID)
Returns the settings object for this child with the given id. A new Settings object will be created for the child if a child doesn't exist with the given id.
Parameters:
childID - The id for the child.
Returns:
The child Settings object.

getCustomizer

public SettingsCustomizer getCustomizer()
Returns the settings customizer UI component that the preferences dialog box can display to allow the user to customize this settings object.

getSetting

public java.lang.String getSetting(java.lang.String settingName)
Retrieve the setting with the given name from this Settings object.
Parameters:
settingName - The name of the setting to retreive.
Returns:
The value of the setting, or null if no Settings with the given name exists.

getSetting

public java.lang.String getSetting(java.lang.String name,
                                   java.lang.String defaultValue)
Retrieve the setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsBoolean

public boolean getSettingAsBoolean(java.lang.String name,
                                   boolean defaultValue)
Retrieves a boolean setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsByte

public byte getSettingAsByte(java.lang.String name,
                             byte defaultValue)
Retrieves a byte-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsCharacter

public char getSettingAsCharacter(java.lang.String name,
                                  char defaultValue)
Retrieves a char-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsDouble

public double getSettingAsDouble(java.lang.String name,
                                 double defaultValue)
Retrieves a double-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsFloat

public float getSettingAsFloat(java.lang.String name,
                               float defaultValue)
Retrieves a float-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsInt

public int getSettingAsInt(java.lang.String name,
                           int defaultValue)
Retrieves an int-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsLong

public long getSettingAsLong(java.lang.String name,
                             long defaultValue)
Retrieves a long-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

getSettingAsShort

public short getSettingAsShort(java.lang.String name,
                               short defaultValue)
Retrieves a short-sized setting with the given name from this Settings object.
Parameters:
name - The name of the setting to retreive.
defaultValue - The value to return if the settings doesn't exists.
Returns:
The value of the setting, or defaultValue if no Settings with the given name exists.

setSettingAsBoolean

public void setSettingAsBoolean(java.lang.String name,
                                boolean value)
Sets a boolean-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsByte

public void setSettingAsByte(java.lang.String name,
                             byte value)
Sets a byte-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsCharacter

public void setSettingAsCharacter(java.lang.String name,
                                  char value)
Sets a char-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsDouble

public void setSettingAsDouble(java.lang.String name,
                               double value)
Sets a double-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsFloat

public void setSettingAsFloat(java.lang.String name,
                              float value)
Sets a float-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsInt

public void setSettingAsInt(java.lang.String name,
                            int value)
Sets an int-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsLong

public void setSettingAsLong(java.lang.String name,
                             long value)
Sets a long-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

setSettingAsShort

public void setSettingAsShort(java.lang.String name,
                              short value)
Sets a short-sized setting with the given name in this Settings object.
Parameters:
name - The name of the setting to retreive.
value - The new value of the setting.

hasChild

public boolean hasChild(java.lang.String childID)
Tests if a child with the given childId exists in this Settings object.
Parameters:
childID - The id of the child.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Unregisters a listener from this Settings object. The listener will no longer receive notification of changes to this Settings object.
Parameters:
listsner - The listener to unregister.

setCustomizer

public void setCustomizer(SettingsCustomizer customizer)
Associate a settings customizer with this Settings obeject. The settings customizer will be used by the preferences dialog to allow the user to customize the settings in this Settings object.

setSetting

public void setSetting(java.lang.String settingName,
                       java.lang.String settingValue)
Sets a setting with the given name in this Settings object.
Parameters:
settingName - The name of the setting to be set.
settingValue - The new value of the setting.