Utils
Class Settings

java.lang.Object
  extended by Utils.Settings

public class Settings
extends java.lang.Object

Represents the value of settings (including retutning default settings). The constructor checks the validity of the settings past to it.

Settings can either be root level settings or within a group. Only a single level of groups is a allowed (i.e. a groups within a group is disallowed).

PossibleSettings represents the list of settings that are possible. Each setting can be optional or compulsory. Groups can like wise be optional or compulsory. If a group is optional then any settings within it which are comulsory are only compulsory when the group is present.

SetSettings represents the current value of settings, e.g. from a settings file or from a GUI. SetSettings represents values set by a user whereas this class represents values need by a program - it takes into account default values and the constructor of this class ensures that all needed settings are set and there aren't any unexpected settings (as this is probably an input error).

Version:
1.0

Constructor Summary
Settings(PossibleSettings need, SetSettings set)
          Creates an instance of this class
 
Method Summary
 java.lang.String getSetting(java.lang.String setting)
          Gets the value of a root level setting
 java.lang.String getSetting(java.lang.String group, java.lang.String setting)
          Gets the value of a setting within a group
 boolean hasGroup(java.lang.String group)
          Tests whether a group is present
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Settings

public Settings(PossibleSettings need,
                SetSettings set)
         throws SettingException
Creates an instance of this class

Parameters:
need - Settings needed by the program
set - Settings set by the user
Throws:
SettingException - If a setting that needs to be set isn't or an unexpected setting is set
Method Detail

getSetting

public java.lang.String getSetting(java.lang.String setting)
                            throws SettingException
Gets the value of a root level setting

Parameters:
setting - The setting's name
Returns:
The value of the setting
Throws:
SettingException - Thrown if there is no default value (this shouldn't occur due to the chacks at construction).

getSetting

public java.lang.String getSetting(java.lang.String group,
                                   java.lang.String setting)
                            throws SettingException
Gets the value of a setting within a group

Parameters:
group - The group's name
setting - The settings name
Returns:
The value of the setting
Throws:
SettingException - Thrown if there is no default value (this shouldn't occur due to the chacks at construction).

hasGroup

public boolean hasGroup(java.lang.String group)
Tests whether a group is present

Parameters:
group - The group's name
Returns:
Whether the group is present