Top Description Fields Constructors Methods
com.typesafe.config

public final Class ConfigParseOptions

extends Object
Class Inheritance
Imports
com.typesafe.config.impl.ConfigImplUtil

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)

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final ClassLoader
pack-priv final ConfigIncluder
pack-priv final String
pack-priv final ConfigSyntax

Constructor Summary

AccessConstructor and Description
private
ConfigParseOptions(ConfigSyntax syntax, String originDescription, boolean allowMissing, ConfigIncluder includer, ClassLoader classLoader)

Method Summary

Modifier and TypeMethod and Description
public ConfigParseOptions

Returns:

new version of the parse options with different includer
appendIncluder
(ConfigIncluder
the includer to append (may not be null)
includer
)

Appends a ConfigIncluder which customizes how includes are handled.

public static ConfigParseOptions

Returns:

the default parse options
defaults
()

Gets an instance of ConfigParseOptions with all fields set to the default values.

public boolean

Returns:

whether we allow missing files
getAllowMissing
()

Gets the current "allow missing" flag.

public ClassLoader

Returns:

class loader to use
getClassLoader
()

Get the class loader; never returns null, if the class loader was unset, returns Thread.currentThread().getContextClassLoader().

public ConfigIncluder

Returns:

current includer or null
getIncluder
()

Gets the current includer (will be null for the default includer).

public String

Returns:

the current origin description or null
getOriginDescription
()

Gets the current origin description, which may be null for "automatic".

public ConfigSyntax

Returns:

the current syntax or null
getSyntax
()

Gets the current syntax option, which may be null for "any".

public ConfigParseOptions

Returns:

new version of the parse options with different includer
prependIncluder
(ConfigIncluder
the includer to prepend (may not be null)
includer
)

Prepends a ConfigIncluder which customizes how includes are handled.

public ConfigParseOptions

Returns:

options with the "allow missing" flag set
setAllowMissing
(boolean
true to silently ignore missing item
allowMissing
)

Set to false to throw an exception if the item being parsed (for example a file) is missing.

public ConfigParseOptions

Returns:

options with the class loader set
setClassLoader
(ClassLoader
a class loader or null to use thread context class loader
loader
)

Set the class loader.

public ConfigParseOptions

Returns:

new version of the parse options with different includer
setIncluder
(ConfigIncluder
the includer to use or null for default
includer
)

Set a ConfigIncluder which customizes how includes are handled.

public ConfigParseOptions

Returns:

options with the origin description set
setOriginDescription
(String
description to put in the ConfigOrigin
originDescription
)

Set a description for the thing being parsed.

public ConfigParseOptions

Returns:

options with the syntax set
setSyntax
(ConfigSyntax
a syntax or null for best guess
syntax
)

Set the file format.

public ConfigParseOptions

Returns:

options with the syntax set
setSyntaxFromFilename
(String
a configuration file name
filename
)

Set the file format.

pack-priv ConfigParseOptions
withFallbackOriginDescription(String originDescription)

this is package-private, not public API

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowMissingback to summary
pack-priv final boolean allowMissing
classLoaderback to summary
pack-priv final ClassLoader classLoader
includerback to summary
pack-priv final ConfigIncluder includer
originDescriptionback to summary
pack-priv final String originDescription
syntaxback to summary
pack-priv final ConfigSyntax syntax

Constructor Detail

ConfigParseOptionsback to summary
private ConfigParseOptions(ConfigSyntax syntax, String originDescription, boolean allowMissing, ConfigIncluder includer, ClassLoader classLoader)

Method Detail

appendIncluderback to summary
public ConfigParseOptions appendIncluder(ConfigIncluder includer)

Appends a ConfigIncluder which customizes how includes are handled. To append, the library calls ConfigIncluder#withFallback on the existing includer.

Parameters
includer:ConfigIncluder

the includer to append (may not be null)

Returns:ConfigParseOptions

new version of the parse options with different includer

defaultsback to summary
public static ConfigParseOptions defaults()

Gets an instance of ConfigParseOptions with all fields set to the default values. Start with this instance and make any changes you need.

Returns:ConfigParseOptions

the default parse options

getAllowMissingback to summary
public boolean getAllowMissing()

Gets the current "allow missing" flag.

Returns:boolean

whether we allow missing files

getClassLoaderback to summary
public ClassLoader getClassLoader()

Get the class loader; never returns null, if the class loader was unset, returns Thread.currentThread().getContextClassLoader().

Returns:ClassLoader

class loader to use

getIncluderback to summary
public ConfigIncluder getIncluder()

Gets the current includer (will be null for the default includer).

Returns:ConfigIncluder

current includer or null

getOriginDescriptionback to summary
public String getOriginDescription()

Gets the current origin description, which may be null for "automatic".

Returns:String

the current origin description or null

getSyntaxback to summary
public ConfigSyntax getSyntax()

Gets the current syntax option, which may be null for "any".

Returns:ConfigSyntax

the current syntax or null

prependIncluderback to summary
public ConfigParseOptions prependIncluder(ConfigIncluder includer)

Prepends a ConfigIncluder which customizes how includes are handled. To prepend your includer, the library calls ConfigIncluder#withFallback on your includer to append the existing includer to it.

Parameters
includer:ConfigIncluder

the includer to prepend (may not be null)

Returns:ConfigParseOptions

new version of the parse options with different includer

setAllowMissingback to summary
public ConfigParseOptions setAllowMissing(boolean allowMissing)

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:boolean

true to silently ignore missing item

Returns:ConfigParseOptions

options with the "allow missing" flag set

setClassLoaderback to summary
public ConfigParseOptions setClassLoader(ClassLoader loader)

Set the class loader. If set to null, Thread.currentThread().getContextClassLoader() will be used.

Parameters
loader:ClassLoader

a class loader or null to use thread context class loader

Returns:ConfigParseOptions

options with the class loader set

setIncluderback to summary
public ConfigParseOptions setIncluder(ConfigIncluder includer)

Set a ConfigIncluder which customizes how includes are handled. null means to use the default includer.

Parameters
includer:ConfigIncluder

the includer to use or null for default

Returns:ConfigParseOptions

new version of the parse options with different includer

setOriginDescriptionback to summary
public ConfigParseOptions setOriginDescription(String originDescription)

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 the ConfigOrigin of the parsed values.

Parameters
originDescription:String

description to put in the ConfigOrigin

Returns:ConfigParseOptions

options with the origin description set

setSyntaxback to summary
public ConfigParseOptions setSyntax(ConfigSyntax syntax)

Set the file format. If set to null, try to guess from any available filename extension; if guessing fails, assume ConfigSyntax#CONF.

Parameters
syntax:ConfigSyntax

a syntax or null for best guess

Returns:ConfigParseOptions

options with the syntax set

setSyntaxFromFilenameback to summary
public ConfigParseOptions setSyntaxFromFilename(String filename)

Set the file format. If set to null, assume ConfigSyntax#CONF.

Parameters
filename:String

a configuration file name

Returns:ConfigParseOptions

options with the syntax set

withFallbackOriginDescriptionback to summary
pack-priv ConfigParseOptions withFallbackOriginDescription(String originDescription)

this is package-private, not public API