Package uk.ac.manchester.spinnaker.utils
Class RawConfigParser
java.lang.Object
uk.ac.manchester.spinnaker.utils.RawConfigParser
A cut-down limited version of the parser used in Python.
- Author:
- Donal Fellows
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a configuration with no values defined in it.RawConfigParser(File file) Create a configuration from the given configuration file.protectedRawConfigParser(String delimiters, String comments) Create a basic configuration parser.RawConfigParser(URL resource) Create a configuration from the given configuration file. -
Method Summary
Modifier and TypeMethodDescriptionGet a value from the config.getBoolean(String section, String option) Get a value from the config.Get a value from the config.protected booleanHow to decide if a value is to be treated asnull.protected StringnormaliseOptionName(String name) How to convert an option name into canonical form.protected StringnormaliseSectionName(String name) How to convert a section name into canonical form.voidRead a configuration file.voidRead a configuration file.
-
Constructor Details
-
RawConfigParser
Create a basic configuration parser.- Parameters:
delimiters- the option/value delimiter characters.comments- the comment delimiter characters.
-
RawConfigParser
public RawConfigParser()Create a configuration with no values defined in it. -
RawConfigParser
Create a configuration from the given configuration file. This is designed to be used withClass.getResource(String).- Parameters:
resource- The handle to the configuration file.- Throws:
RuntimeException- If the file can't be read. (NB: notIOException.)
-
RawConfigParser
Create a configuration from the given configuration file.- Parameters:
file- The handle to the configuration file.- Throws:
RuntimeException- If the file can't be read. (NB: notIOException.)
-
-
Method Details
-
normaliseSectionName
How to convert a section name into canonical form.- Parameters:
name- The raw section name.- Returns:
- The canonicalised section name.
-
normaliseOptionName
How to convert an option name into canonical form.- Parameters:
name- The raw option name.- Returns:
- The canonicalised option name.
-
read
Read a configuration file.- Parameters:
resource- Where the file is.- Throws:
IOException- if the reading fails.
-
read
Read a configuration file.- Parameters:
file- Where the file is.- Throws:
IOException- if the reading fails.
-
isNone
How to decide if a value is to be treated asnull.- Parameters:
value- The value to examine- Returns:
- True iff the value is a
null-equivalent.
-
getInt
Get a value from the config.- Parameters:
section- The section to look in.option- The option to look at.- Returns:
- The option value, or
nullif it is absent.
-
getBoolean
Get a value from the config.- Parameters:
section- The section to look in.option- The option to look at.- Returns:
- The option value, or
nullif it is absent.
-
get
Get a value from the config.- Parameters:
section- The section to look in.option- The option to look at.- Returns:
- The option value, or
nullif it is absent.
-