See: Description
Interface | Description |
---|---|
Config |
An immutable map from config paths to config values.
|
ConfigIncludeContext |
Context provided to a
ConfigIncluder ; this interface is only useful
inside a ConfigIncluder implementation, and is not intended for apps
to implement. |
ConfigIncluder |
Implement this interface and provide an instance to
ConfigParseOptions.setIncluder() to
customize handling of include statements in config files. |
ConfigIncluderClasspath |
Implement this in addition to
ConfigIncluder if you want to
support inclusion of files with the include classpath("resource")
syntax. |
ConfigIncluderFile |
Implement this in addition to
ConfigIncluder if you want to
support inclusion of files with the include file("filename") syntax. |
ConfigIncluderURL |
Implement this in addition to
ConfigIncluder if you want to
support inclusion of files with the include url("http://example.com")
syntax. |
ConfigList |
Subtype of
ConfigValue representing a list value, as in JSON's
[1,2,3] syntax. |
ConfigLoadingStrategy |
This method allows you to alter default config loading strategy for all the code which
calls
ConfigFactory.load(java.lang.String) . |
ConfigMergeable |
Marker for types whose instances can be merged, that is
Config and
ConfigValue . |
ConfigObject |
Subtype of
ConfigValue representing an object (AKA dictionary or map)
value, as in JSON's curly brace { "a" : 42 } syntax. |
ConfigOrigin |
Represents the origin (such as filename and line number) of a
ConfigValue for use in error messages. |
ConfigParseable |
An opaque handle to something that can be parsed, obtained from
ConfigIncludeContext . |
ConfigResolver |
Implement this interface and provide an instance to
ConfigResolveOptions.appendResolver()
to provide custom behavior when unresolved substitutions are encountered
during resolution. |
ConfigValue |
An immutable value, following the JSON type
schema.
|
Class | Description |
---|---|
ConfigBeanFactory |
Factory for automatically creating a Java class from a
Config . |
ConfigException.ValidationProblem |
Information about a problem that occurred in
Config.checkValid(com.typesafe.config.Config, java.lang.String...) . |
ConfigFactory |
Contains static methods for creating
Config instances. |
ConfigMemorySize |
An immutable class representing an amount of memory.
|
ConfigOriginFactory |
This class contains some static factory methods for building a
ConfigOrigin . |
ConfigParseOptions |
A set of options related to parsing.
|
ConfigRenderOptions |
A set of options related to rendering a
ConfigValue . |
ConfigResolveOptions |
A set of options related to resolving substitutions.
|
ConfigUtil |
Contains static utility methods.
|
ConfigValueFactory |
This class holds some static factory methods for building
ConfigValue
instances. |
DefaultConfigLoadingStrategy |
Default config loading strategy.
|
Enum | Description |
---|---|
ConfigSyntax | |
ConfigValueType |
The type of a configuration value (following the JSON type schema).
|
Exception | Description |
---|---|
ConfigException |
All exceptions thrown by the library are subclasses of
ConfigException . |
ConfigException.BadBean |
Some problem with a JavaBean we are trying to initialize.
|
ConfigException.BadPath |
Exception indicating that a path expression was invalid.
|
ConfigException.BadValue |
Exception indicating that a value was messed up, for example you may have
asked for a duration and the value can't be sensibly parsed as a
duration.
|
ConfigException.BugOrBroken |
Exception indicating that there's a bug in something (possibly the
library itself) or the runtime environment is broken.
|
ConfigException.Generic |
Exception that doesn't fall into any other category.
|
ConfigException.IO |
Exception indicating that there was an IO error.
|
ConfigException.Missing |
Exception indicates that the setting was never set to anything, not even
null.
|
ConfigException.NotResolved |
Exception indicating that you tried to use a function that requires
substitutions to be resolved, but substitutions have not been resolved
(that is,
Config.resolve() was not called). |
ConfigException.Null |
Exception indicates that the setting was treated as missing because it
was set to null.
|
ConfigException.Parse |
Exception indicating that there was a parse error.
|
ConfigException.UnresolvedSubstitution |
Exception indicating that a substitution did not resolve to anything.
|
ConfigException.ValidationFailed |
Exception indicating that
Config.checkValid(com.typesafe.config.Config, java.lang.String...) found validity
problems. |
ConfigException.WrongType |
Exception indicating that the type of a value does not match the type you
requested.
|
Annotation Type | Description |
---|---|
Optional |
Allows an config property to be
null . |
An API for loading and using configuration files, see the project site for more information.
Typically you would load configuration with a static method from ConfigFactory
and then use
it with methods in the Config
interface. Configuration may be in the form of JSON files,
Java properties, or HOCON files; you may also
build your own configuration in code or from your own file formats.
An application can simply call ConfigFactory.load()
and place
its configuration in "application.conf" on the classpath.
If you use the default configuration from ConfigFactory.load()
there's no need to pass a configuration to your libraries
and frameworks, as long as they all default to this same default, which they should.
Example application code: Java and Scala.
Showing a couple of more special-purpose features, a more complex example: Java and Scala.
A library or framework should ship a file "reference.conf" in its jar, and allow an application to pass in a
Config
to be used for the library. If no Config
is provided,
call ConfigFactory.load()
to get the default one. Typically a library might offer two constructors, one with a Config
parameter
and one which uses ConfigFactory.load()
.
Example library code: Java and Scala.
Check out the full examples directory on GitHub.
What else to read:
Config
..conf
files in addition to .json
and .properties
,
see the README for some short examples
and the full HOCON spec for the long version.