|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object IniSettings
public class IniSettings
This is a generic class for handling settings. It behaves like the Properties and Preferences class from the java library, but it extends the functionality by offering also default values and checking against legal values. For this purpose it will maintain two internal maps, both having as keys the setting's name; one having as values the actual values of the setting (be they default or user defined) and the other one holding the regexps to validate the value pushed by the user.
This class is meant to handle settings that are presented as a key-value pair, e.g.
key = value (syntax is not important here).
Note that the key and the value can be separated by anything, including blanks. This is governed by the rules in the SettingsFile class.
I call this ini-style settings, because they are mostly found in .ini configuration files. The most popular example may be the Linux kernel config file (please hold the flames for calling the kernel config file by an M$-consacrated name - only the logic of the file is similar)
Another feature is that if specified so in the constructor (or alternatively by default), the dimension of the respective settings collection is fixed after construction, meaning the user cannot add new settings to the collection.
FstabSettings
Field Summary | |
---|---|
static LocaleTools |
lt
The LocaleTools object. |
Constructor Summary | |
---|---|
IniSettings()
The default constructor is not initializing the maps, but just setting the expandable parameter to true - it's not possible to have the maps uninitialized AND not be able to extend them afterwards. |
|
IniSettings(ArrayList<String> names)
The user can also call a constructor with only one array of strings, in which case the regular expression will admit any values and the default values will be set to empty strings. |
|
IniSettings(ArrayList<String> names,
ArrayList<String> values)
The user can also call a constructor with only two arrays of strings, in which case the regular expression will admit any values. |
|
IniSettings(ArrayList<String> names,
ArrayList<String> values,
ArrayList<String> laws)
The user can also call a constructor without the boolean param, in this case the default value is FALSE. |
|
IniSettings(ArrayList<String> names,
ArrayList<String> values,
ArrayList<String> laws,
boolean expandable)
The main constructor function, inputing the string arrays into the internal maps. |
|
IniSettings(ArrayList<String> names,
ArrayList<String> values,
boolean expandable)
The user can also call a constructor with only two arrays of strings, in which case the regular expression will admit any values. |
|
IniSettings(ArrayList<String> names,
boolean expandable)
The user can also call a constructor with only one array of strings, in which case the regular expression will admit any values and the default values will be set to empty strings. |
Method Summary | |
---|---|
boolean |
containsName(String name)
This method checks if the specified setting is defined. |
String |
getValue(String name)
This method returns the stored value for setting name |
boolean |
isExpandable()
This methods lets the user check the 'expandability' of this object |
Set<String> |
names()
This method returns a String Set containing all the defined settings |
void |
putName(String name,
String law)
This method extends the settings class with a new name |
String |
putValue(String name,
String value)
This method first checks that the value matches the regular expression and if it does stores it. |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static LocaleTools lt
LocaleTools
object.
Constructor Detail |
---|
public IniSettings(ArrayList<String> names, ArrayList<String> values, ArrayList<String> laws, boolean expandable)
names
- The string array containing the names of the settings to be handled by this objectvalues
- The string array containing the default values for the corresponding settingslaws
- The regular expression that any value should match to be considered legalexpandable
- True if the user would like to be able to later add new settings to this objectpublic IniSettings(ArrayList<String> names, ArrayList<String> values, ArrayList<String> laws)
names
- The string array containing the names of the settings to be handled by this objectvalues
- The string array containing the default values for the corresponding settingslaws
- The regular expression that any value should match to be considered legalpublic IniSettings(ArrayList<String> names, ArrayList<String> values, boolean expandable)
names
- The string array containing the names of the settings to be handled by this objectvalues
- The string array containing the default values for the corresponding settingsexpandable
- True if the user would like to be able to later add new settings to this objectpublic IniSettings(ArrayList<String> names, ArrayList<String> values)
names
- The string array containing the names of the settings to be handled by this objectvalues
- The string array containing the default values for the corresponding settingspublic IniSettings(ArrayList<String> names, boolean expandable)
names
- The string array containing the names of the settings to be handled by this objectexpandable
- True if the user would like to be able to later add new settings to this objectpublic IniSettings(ArrayList<String> names)
names
- The string array containing the names of the settings to be handled by this objectpublic IniSettings()
Method Detail |
---|
public String putValue(String name, String value)
name
- The name of the settingvalue
- The correspondig value for setting name
public void putName(String name, String law)
name
- The name of the new settinglaw
- The regular expression corresponding to the new settingpublic String getValue(String name)
name
- The setting whose value it is querried
public boolean containsName(String name)
name
- The setting whose presence is checked
public boolean isExpandable()
true
if the object is expandable.public Set<String> names()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |