misim.util
Class SettingsController
java.lang.Object
|
+--misim.util.SettingsController
- public class SettingsController
- extends java.lang.Object
This class is intended to read and write settings generating
SettingsGroups, containing individual settings.
In general a settings file has one or more settings groups, with
each group containing zero or more settings. A setting
has a name - any String, and a value - also any String.
The first Settings Group is called 'main', all subsequent
groups are marked with a string in square brackets: [like this]
Settings are stored as: setting name=value, leading and trailing
spaces are stripped from both the name and value.
Any blank line, or line starting with the '#' symbol is
skipped. If a line contains the two character string '//' all
text after the '//' is ignored.
Field Summary |
static java.lang.String |
MAIN_GROUP
Constant name for the main group read from the settings file |
Constructor Summary |
SettingsController()
Constructor to create an empty Settings object |
SettingsController(java.io.BufferedReader input,
java.util.Vector settingsLog)
Constructor to create a Settings object and populate it with
settings from the given file |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAIN_GROUP
public static java.lang.String MAIN_GROUP
- Constant name for the main group read from the settings file
SettingsController
public SettingsController()
- Constructor to create an empty Settings object
SettingsController
public SettingsController(java.io.BufferedReader input,
java.util.Vector settingsLog)
throws java.io.IOException
- Constructor to create a Settings object and populate it with
settings from the given file
- Parameters:
input
- A BufferedReader for the settings filesettingsLog
- A Vector of (String) log messages generated whilst
reading the file.- Throws:
java.io.IOException
- If an error occurs whilst reading the file
readSettings
public int readSettings(java.io.BufferedReader input,
java.util.Vector settingsLog)
throws java.io.IOException
- Read a settings file. Note that this appends settings to the existing
settings list.
- Parameters:
input
- A BufferedReader for the settings filesettingsLog
- A Vector of (String) log messages generated whilst
reading the file.- Returns:
- The number of errors encountered whislt reading the file.
- Throws:
java.io.IOException
- If an error occurs whilst reading the file
getErrorCount
public int getErrorCount()
- Return the number of errors encountered whilst reading the most
recent settings file
- Returns:
- The number of errors encountered
getGroupCount
public int getGroupCount()
- Return the number of groups that this Settings object contains
- Returns:
- The number of groups
getSettingsGroup
public SettingsGroup getSettingsGroup(java.lang.String groupName)
- Get the named group
- Parameters:
groupName
- The name of the group to return- Returns:
- The requested group, or null if it does not exist
getSettingsGroup
public SettingsGroup getSettingsGroup(int index)
- Get the SettingsGroup with the given index
- Parameters:
The
- index of the desired group- Returns:
- The group requested