Import this object's contents (import Configuration.Implicits._
)
to get the implicit converters.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read. The predefined sections are defined in a map of maps. The outer map is keyed by predefined section name. The inner maps consist of options and their values. For instance, to read a configuration file, giving it access to certain command line parameters, you could do something like this:
object Foo { def main(args: Array[String]) = { // You'd obviously want to do some real argument checking here. val configFile = args(0) val name = args(1) val ipAddress = args(2) val sections = Map("args" -> Map("name" -> name, "ip" -> ipAddress)) val config = Configuration(Source.fromFile(new File(configFile)), sections) ... } }
scala.io.Source
object to read
the predefined sections. An empty map means
there are no predefined sections.
not (true
). Default: false
Regular expression that matches legal section names.
Regular expression that matches comment lines.
Right(config)
on success, Left(error)
on error.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read. The predefined sections are defined in a map of maps. The outer map is keyed by predefined section name. The inner maps consist of options and their values. For instance, to read a configuration file, giving it access to certain command line parameters, you could do something like this:
object Foo { def main(args: Array[String]) = { // You'd obviously want to do some real argument checking here. val configFile = args(0) val name = args(1) val ipAddress = args(2) val sections = Map("args" -> Map("name" -> name, "ip" -> ipAddress)) val config = Configuration(Source.fromFile(new File(configFile)), sections) ... } }
scala.io.Source
object to read
the predefined sections. An empty map means there are no predefined sections.
Right[Configuration]
on success, Left(error)
on error.
Read a configuration file, returning an Either
, instead of throwing
an exception on error.
Read a configuration file, returning an Either
, instead of throwing
an exception on error.
scala.io.Source
object to read
Regular expression that matches legal section names. Defaults as described above.
Regular expression that matches comment lines. Default: "^\s*(#.*)$"
Partial function used to transform option names into keys. The default function transforms the names to lower case.
a function to call if an option isn't found in
the configuration, or None. The function
must take a section name and an option name as
parameters. It must return Failure
on error,
Success(None)
if the value isn't found, and
Success Right(Some(string))
if the value is
found.
true
does "safe" substitutions, with
substitutions of nonexistent values replaced by
empty strings. false
ensures that bad
substitutions result in errors (or None
in
functions, like get()
, that return Option
values).
Right(config)
on success, Left(error)
on error.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read. The predefined sections are defined in a map of maps. The outer map is keyed by predefined section name. The inner maps consist of options and their values. For instance, to read a configuration file, giving it access to certain command line parameters, you could do something like this:
object Foo { def main(args: Array[String]) = { // You'd obviously want to do some real argument checking here. val configFile = args(0) val name = args(1) val ipAddress = args(2) val sections = Map("args" -> Map("name" -> name, "ip" -> ipAddress)) val config = Configuration.read(Source.fromFile(new File(configFile)), sections) ... } }
scala.io.Source
object to read
the predefined sections. An empty map means
there are no predefined sections.
not (true
). Default: false
Regular expression that matches legal section names.
Regular expression that matches comment lines.
Success[Configuration]
on success, Failure(exception)
on error.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read.
Read a configuration file, permitting some predefined sections to be added to the configuration before it is read. The predefined sections are defined in a map of maps. The outer map is keyed by predefined section name. The inner maps consist of options and their values. For instance, to read a configuration file, giving it access to certain command line parameters, you could do something like this:
object Foo { def main(args: Array[String]) = { // You'd obviously want to do some real argument checking here. val configFile = args(0) val name = args(1) val ipAddress = args(2) val sections = Map("args" -> Map("name" -> name, "ip" -> ipAddress)) val config = Configuration.read(Source.fromFile(new File(configFile)), sections) ... } }
scala.io.Source
object to read
the predefined sections. An empty map means there are no predefined sections.
Success[Configuration]
on success, Failure(exception)
on error.
Read a configuration file, returning an Either
, instead of throwing
an exception on error.
Read a configuration file, returning an Either
, instead of throwing
an exception on error.
scala.io.Source
object to read
Regular expression that matches legal section names. Defaults as described above.
Regular expression that matches comment lines. Default: "^\s*(#.*)$"
Partial function used to transform option names into keys. The default function transforms the names to lower case.
a function to call if an option isn't found in
the configuration, or None. The function
must take a section name and an option name as
parameters. It must return Failure
on error,
Success(None)
if the value isn't found, and
Success Right(Some(string))
if the value is
found.
true
does "safe" substitutions, with
substitutions of nonexistent values replaced by
empty strings. false
ensures that bad
substitutions result in errors (or None
in
functions, like get()
, that return Option
values).
Success(config)
on success, Failure(exception)
on error.
Companion object for the
Configuration
class