Package eu.bandm.tools.util
Class SimpleConfig
java.lang.Object
eu.bandm.tools.util.SimpleConfig
Reads simple "key blank value linefeed" lines and
decodes them to configuration parameters.
Used for configuration purposes in all those cases when a
fully fledged "tdom" etc. would be too heavy weight.
This class is intendend to be sub-classed by application specific
configuration handlers, which do further parsing on the values and
offer them in typed and dedicated getter functions.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeyValuePair
(String k, String v) For subsequent modification.protected void
checkNotThere
(String key) protected double
Returns doublce value, throws exception if not parsable.protected int
getInteger
(String key) Returns integer value, throws exception if not parsable.protected String
getNotEmpty
(String key) Returns trimmed value, iff there is a key, and the value is not empty, else null.protected String
getObligate
(String key) Throws IOException iff no entry with given key, else returns trimmed value (which may have zero length).protected Double
getWithDefault
(String key, double def) Delivers the default if no entry with the given key.protected Integer
getWithDefault
(String key, int def) Delivers the default if no entry with the given key.protected String
getWithDefault
(String key, String def) Delivers the default if no entry with the given key.void
Reads a file with key value pairs line per line and stores key/value pairs into the mapkeyValue
.protected IllegalArgumentException
void
For subsequent modification.
-
Field Details
-
BLANK
public static final char BLANK- See Also:
-
HASH
public static final char HASH- See Also:
-
initializedFrom
-
keyValue
-
-
Constructor Details
-
SimpleConfig
public SimpleConfig()
-
-
Method Details
-
noEntry
-
getObligate
Throws IOException iff no entry with given key, else returns trimmed value (which may have zero length).- Throws:
IllegalArgumentException
-
getWithDefault
Delivers the default if no entry with the given key. -
getWithDefault
Delivers the default if no entry with the given key. -
getWithDefault
Delivers the default if no entry with the given key. -
getNotEmpty
Returns trimmed value, iff there is a key, and the value is not empty, else null. -
getInteger
Returns integer value, throws exception if not parsable. -
getDouble
Returns doublce value, throws exception if not parsable. -
checkNotThere
-
addKeyValuePair
For subsequent modification. -
removeKey
For subsequent modification. -
getConfigurationDataFile
-
init
Reads a file with key value pairs line per line and stores key/value pairs into the mapkeyValue
.
Every read line is first trimmed, seeString.trim()
and then further analysed as follows:
-