Package com.typesafe.config
Class ConfigParseOptions
java.lang.Object
com.typesafe.config.ConfigParseOptions
A set of options related to parsing.
This object is immutable, so the "setters" return a new object.
Here is an example of creating a custom ConfigParseOptions:
ConfigParseOptions options = ConfigParseOptions.defaults()
.setSyntax(ConfigSyntax.JSON)
.setAllowMissing(false)
-
Method Summary
Modifier and TypeMethodDescriptionappendIncluder(ConfigIncluder includer) Appends aConfigIncluderwhich customizes how includes are handled.static ConfigParseOptionsdefaults()Gets an instance ofConfigParseOptionswith all fields set to the default values.booleanGets the current "allow missing" flag.Get the class loader; never returnsnull, if the class loader was unset, returnsThread.currentThread().getContextClassLoader().Gets the current includer (will be null for the default includer).Gets the current origin description, which may be null for "automatic".Gets the current syntax option, which may be null for "any".prependIncluder(ConfigIncluder includer) Prepends aConfigIncluderwhich customizes how includes are handled.setAllowMissing(boolean allowMissing) Set to false to throw an exception if the item being parsed (for example a file) is missing.setClassLoader(ClassLoader loader) Set the class loader.setIncluder(ConfigIncluder includer) Set aConfigIncluderwhich customizes how includes are handled.setOriginDescription(String originDescription) Set a description for the thing being parsed.setSyntax(ConfigSyntax syntax) Set the file format.setSyntaxFromFilename(String filename) Set the file format.
-
Method Details
-
defaults
Gets an instance ofConfigParseOptionswith all fields set to the default values. Start with this instance and make any changes you need.- Returns:
- the default parse options
-
setSyntax
Set the file format. If set to null, try to guess from any available filename extension; if guessing fails, assumeConfigSyntax.CONF.- Parameters:
syntax- a syntax ornullfor best guess- Returns:
- options with the syntax set
-
setSyntaxFromFilename
Set the file format. If set to null, assumeConfigSyntax.CONF.- Parameters:
filename- a configuration file name- Returns:
- options with the syntax set
-
getSyntax
Gets the current syntax option, which may be null for "any".- Returns:
- the current syntax or null
-
setOriginDescription
Set a description for the thing being parsed. In most cases this will be set up for you to something like the filename, but if you provide just an input stream you might want to improve on it. Set to null to allow the library to come up with something automatically. This description is the basis for theConfigOriginof the parsed values.- Parameters:
originDescription- description to put in theConfigOrigin- Returns:
- options with the origin description set
-
getOriginDescription
Gets the current origin description, which may be null for "automatic".- Returns:
- the current origin description or null
-
setAllowMissing
Set to false to throw an exception if the item being parsed (for example a file) is missing. Set to true to just return an empty document in that case. Note that this setting applies on only to fetching the root document, it has no effect on any nested includes.- Parameters:
allowMissing- true to silently ignore missing item- Returns:
- options with the "allow missing" flag set
-
getAllowMissing
public boolean getAllowMissing()Gets the current "allow missing" flag.- Returns:
- whether we allow missing files
-
setIncluder
Set aConfigIncluderwhich customizes how includes are handled. null means to use the default includer.- Parameters:
includer- the includer to use or null for default- Returns:
- new version of the parse options with different includer
-
prependIncluder
Prepends aConfigIncluderwhich customizes how includes are handled. To prepend your includer, the library callsConfigIncluder.withFallback(com.typesafe.config.ConfigIncluder)on your includer to append the existing includer to it.- Parameters:
includer- the includer to prepend (may not be null)- Returns:
- new version of the parse options with different includer
-
appendIncluder
Appends aConfigIncluderwhich customizes how includes are handled. To append, the library callsConfigIncluder.withFallback(com.typesafe.config.ConfigIncluder)on the existing includer.- Parameters:
includer- the includer to append (may not be null)- Returns:
- new version of the parse options with different includer
-
getIncluder
Gets the current includer (will be null for the default includer).- Returns:
- current includer or null
-
setClassLoader
Set the class loader. If set to null,Thread.currentThread().getContextClassLoader()will be used.- Parameters:
loader- a class loader ornullto use thread context class loader- Returns:
- options with the class loader set
-
getClassLoader
Get the class loader; never returnsnull, if the class loader was unset, returnsThread.currentThread().getContextClassLoader().- Returns:
- class loader to use
-