|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.Settings
This class keeps track of the settings. It can parse and save settings file content. It provides support for a standard set of settings, but basically anything can be stored in it. Keys used in this file cannot contain KEY_VALUE_SEPARATOR. Whitespace around KEY_VALUE_SEPARATOR is ignored.
Field Summary | |
private static java.lang.String |
COMMENT_MARKER
This field stores the comment marker to put before any comment lines. |
static java.lang.String |
COMPILE_MODE
|
static java.lang.String |
DEFAULT_STDIN
|
static java.lang.String |
DEFAULT_STDOUT
|
static java.lang.String |
KEY_VALUE_SEPARATOR
This string separates keys from values in the settings file. |
private static java.lang.String |
LINEBREAK_CHECK_REGEXP
This pattern matches against 1 or more characters (there is a start of a line in the start of each String, hence ignore the first character), then 1 or more periods where there is at least one start of line (\n\n would match ^^) and then 0 or more other characters. |
static java.lang.String |
MEMORY_SIZE
|
static java.lang.String |
RUN_MODE
|
private java.util.HashMap |
settings
|
static java.lang.String |
STDIN_PATH
|
static java.lang.String |
STDOUT_PATH
|
static java.lang.String |
STDOUT_USE
|
static java.lang.String |
UI_LANGUAGE
This is one of the default settings keys of values that can be stored here. |
Constructor Summary | |
Settings()
This constructor sets up a settings class with no values. |
|
Settings(java.lang.String settingsFileContent)
This constructor sets up a settings class with default values. |
Method Summary | |
private void |
doSetValue(java.lang.String key,
java.lang.Object value)
This method sets a key to a given object value. |
int |
getIntValue(java.lang.String key)
This method returns the value of a certain key. |
java.lang.String[] |
getKeys()
This method returns all the keys defined here. |
java.lang.String |
getStrValue(java.lang.String key)
This method returns the value of a certain key. |
private void |
parseSettingsFile(java.lang.String fileContent)
This method parses the fileContent string and sets up the settings HashMap values accordingly. |
void |
setValue(java.lang.String key,
int value)
This method sets a key to a certain integer value. |
void |
setValue(java.lang.String key,
java.lang.String value)
This method sets a key to a certain string value. |
java.lang.String |
toString()
This method transforms this settings class into a format which can be parsed by parseSettingsFile. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.util.HashMap settings
public static final java.lang.String KEY_VALUE_SEPARATOR
private static final java.lang.String COMMENT_MARKER
private static final java.lang.String LINEBREAK_CHECK_REGEXP
public static final java.lang.String UI_LANGUAGE
public static final java.lang.String RUN_MODE
public static final java.lang.String COMPILE_MODE
public static final java.lang.String DEFAULT_STDIN
public static final java.lang.String STDIN_PATH
public static final java.lang.String DEFAULT_STDOUT
public static final java.lang.String STDOUT_USE
public static final java.lang.String STDOUT_PATH
public static final java.lang.String MEMORY_SIZE
Constructor Detail |
public Settings(java.lang.String settingsFileContent) throws java.text.ParseException
settingsFileContent
- A String containing what has been in
a settings file for parsing.
java.text.ParseException
- If the settings text was not syntactically
correct.public Settings()
Method Detail |
public void setValue(java.lang.String key, java.lang.String value)
key
- The key to point to the value.value
- The value to be stored.
java.lang.IllegalArgumentException
- If the given key contains
KEY_VALUE_SEPARATOR or the value contains a linebreak in the
middle (in the end it does not count), or if either are null.public void setValue(java.lang.String key, int value)
key
- The key to point to the value.value
- The value to be stored.private void doSetValue(java.lang.String key, java.lang.Object value)
key
- The possibly invalid key to point to the value.value
- The value to be stored.
java.lang.IllegalArgumentException
- If the key contains
KEY_VALUE_SEPARATOR or is null.public int getIntValue(java.lang.String key)
key
- The key pointing to the value to be returned.
java.lang.ClassCastException
- If the value was not an int.
java.lang.NullPointerException
- If there was no value stored by that
key (or if the value stored was null for some reason). The
problem is that int cannot be null, while String in getStrValue
can.public java.lang.String getStrValue(java.lang.String key)
key
- The key pointing to the value to be returned.
java.lang.ClassCastException
- If the value was not a String.public java.lang.String[] getKeys()
public java.lang.String toString()
private void parseSettingsFile(java.lang.String fileContent) throws java.text.ParseException
fileContent
- A String containing what has been in
a settings file for parsing.
java.text.ParseException
- If the settings text was not syntactically
correct.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |