miSim

misim.util
Class SettingsGroup

java.lang.Object
  |
  +--misim.util.SettingsGroup

public class SettingsGroup
extends java.lang.Object

A SettingsGroup contains a named collection of settings


Constructor Summary
SettingsGroup(java.lang.String groupName)
          Constructor.
 
Method Summary
 void addSetting(Setting aSetting)
          Add a setting to this group
 int countSettings()
          Return the number of settings that this group contains
 int countSettings(java.lang.String settingName)
          Return the number of settings with the given name that this group contains.
 java.lang.String getName()
          Return the name of this settings group
 Setting getSetting(int index)
          Return the setting at a given index in this group
 Setting getSetting(java.lang.String settingName)
          Retrieve a setting from this group by name.
 Setting getSetting(java.lang.String settingName, int index)
          Retrieve a setting from this group by name and index.
 boolean getSettingBoolean(java.lang.String settingName, boolean defaultValue)
          Get the value of a setting from this group by name.
 int getSettingIntValue(java.lang.String settingName, int defaultValue)
          Get the value of a setting from this group by name.
 java.lang.String getSettingValue(java.lang.String settingName, java.lang.String defaultValue)
          Get the value of a setting from this group by name.
 void removeSetting(Setting aSetting)
          Remove a setting from this group
 void updateSetting(Setting aSetting)
          Update the first setting that matches this setting by name in this group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettingsGroup

public SettingsGroup(java.lang.String groupName)
Constructor. Create a settings group with the given name
Parameters:
groupName - The name for this settings group
Method Detail

getName

public java.lang.String getName()
Return the name of this settings group
Returns:
The name of this group

addSetting

public void addSetting(Setting aSetting)
Add a setting to this group
Parameters:
aSetting - The setting to be added

updateSetting

public void updateSetting(Setting aSetting)
Update the first setting that matches this setting by name in this group. If the setting does not exist, it is created.
Parameters:
aSetting - The setting to be updated

removeSetting

public void removeSetting(Setting aSetting)
Remove a setting from this group
Parameters:
aSetting - The setting to be removed

getSetting

public Setting getSetting(java.lang.String settingName)
Retrieve a setting from this group by name. If more than one setting exists with this name, return the first one found.
Parameters:
settingName - The name of the setting to be retrieved
Returns:
The requested setting, or null if it is not found.

getSetting

public Setting getSetting(java.lang.String settingName,
                          int index)
Retrieve a setting from this group by name and index. The index allows the n-th setting with the given name to be retrieved. The first setting has an index of 0. Setting names are case insensitive here.
Parameters:
settingName - The name of the setting to be retrieved
index - The index of the setting to retrieve
Returns:
The requested setting, or null if it is not found.

getSettingValue

public java.lang.String getSettingValue(java.lang.String settingName,
                                        java.lang.String defaultValue)
Get the value of a setting from this group by name. If more than one setting exists with this name, return the first one found.
Parameters:
settingName - The name of the setting to be retrieved
defaultValue - A default value to return if the setting is not found
Returns:
The value of the requested setting, or the default if not found

getSettingIntValue

public int getSettingIntValue(java.lang.String settingName,
                              int defaultValue)
Get the value of a setting from this group by name. If more than one setting exists with this name, return the first one found. This will also return the default value if the setting exists, but is not a valid number.
Parameters:
settingName - The name of the setting to be retrieved
defaultValue - A default value to return if the setting is not found
Returns:
The value of the requested setting, or the default if not found

getSettingBoolean

public boolean getSettingBoolean(java.lang.String settingName,
                                 boolean defaultValue)
Get the value of a setting from this group by name. If more than one setting exists with this name, return the first one found. This will also return the default value if the setting does not exist.
Parameters:
settingName - The name of the setting to be retrieved
defaultValue - A default value to return if the setting is not found
Returns:
The value of the requested setting, or the default if not found

countSettings

public int countSettings()
Return the number of settings that this group contains
Returns:
The number of settings

countSettings

public int countSettings(java.lang.String settingName)
Return the number of settings with the given name that this group contains. Setting names are case insensitive here.
Parameters:
settingName - The name of the setting to count.
Returns:
The number of settings

getSetting

public Setting getSetting(int index)
Return the setting at a given index in this group
Parameters:
index - The index of the setting to retrieve
Returns:
The requested setting.

miSim