public class Settings
extends java.lang.Object
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
compulsory 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).Constructor and Description |
---|
Settings(PossibleSettings need,
SetSettings set)
Creates an instance of this class
|
Modifier and Type | Method and Description |
---|---|
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
|
public Settings(PossibleSettings need, SetSettings set) throws SettingException
need
- Settings needed by the programset
- Settings set by the userSettingException
- If a setting that needs to be set isn't or an
unexpected setting is setpublic java.lang.String getSetting(java.lang.String setting) throws SettingException
setting
- The setting's nameSettingException
- Thrown if there is no default value (this
shouldn't occur due to the checks at construction).public java.lang.String getSetting(java.lang.String group, java.lang.String setting) throws SettingException
group
- The group's namesetting
- The settings nameSettingException
- Thrown if there is no default value (this
shouldn't occur due to the checks at construction).public boolean hasGroup(java.lang.String group)
group
- The group's name