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.protected
RawConfigParser
(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 boolean
How to decide if a value is to be treated asnull
.protected String
normaliseOptionName
(String name) How to convert an option name into canonical form.protected String
normaliseSectionName
(String name) How to convert a section name into canonical form.void
Read a configuration file.void
Read 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
null
if 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
null
if 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
null
if it is absent.
-