Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.api

public final Class LoadSettingsBuilder

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Objects, .Optional, .Set, java.util.function.IntFunction, .UnaryOperator, org.snakeyaml.engine.v2.common.SpecVersion, org.snakeyaml.engine.v2.env.EnvConfig, org.snakeyaml.engine.v2.exceptions.YamlVersionException, org.snakeyaml.engine.v2.nodes.Tag, org.snakeyaml.engine.v2.schema.JsonSchema, .Schema

Builder pattern implementation for LoadSettings

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private Integer
private int
private final Map<SettingKey, Object>
private IntFunction<List<Object>>
private IntFunction<Map<Object, Object>>
private IntFunction<Set<Object>>
private Optional<EnvConfig>
private String
private int
private boolean
private Schema
private Map<Tag, ConstructNode>
private boolean
private UnaryOperator<SpecVersion>

Constructor Summary

AccessConstructor and Description
pack-priv
LoadSettingsBuilder()

Create builder

Method Summary

Modifier and TypeMethod and Description
public LoadSettings

Returns:

immutable LoadSettings
build
()

Build immutable LoadSettings

public LoadSettingsBuilder

Returns:

the builder with the provided value
setAllowDuplicateKeys
(boolean
- if true, then the non-unique keys in a mapping are allowed (last key wins). False by default.
allowDuplicateKeys
)

YAML 1.2 does require unique keys.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setAllowRecursiveKeys
(boolean
- true to allow recursive structures as keys
allowRecursiveKeys
)

Allow only non-recursive keys for maps and sets.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setBufferSize
(Integer
- buffer size (in bytes) for input data
bufferSize
)

Buffer size for incoming data stream.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setCodePointLimit
(int
- the max allowed size of a single YAML document in a stream
codePointLimit
)

The max amount of code points for every input YAML document in the stream.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setCustomProperty
(SettingKey
- the key
key
,
Object
- the value behind the key
value
)

Provide a custom property to be used later

public LoadSettingsBuilder

Returns:

the builder with the provided value
setDefaultList
(IntFunction<List<Object>>
- specified List implementation (as a function from init size)
defaultList
)

Provide default List implementation.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setDefaultMap
(IntFunction<Map<Object, Object>>
- specified Map implementation (as a function from init size)
defaultMap
)

Provide default Map implementation.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setDefaultSet
(IntFunction<Set<Object>>
- specified Set implementation (as a function from init size)
defaultSet
)

Provide default Set implementation.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setEnvConfig
(Optional<EnvConfig>
- non-empty configuration to substitute variables
envConfig
)

Define EnvConfig to parse ENV format.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setLabel
(String
- meaningful label to indicate the input source
label
)

Label for the input data.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setMaxAliasesForCollections
(int
- max number of aliases. More than 50 might be very dangerous. Default is 50
maxAliasesForCollections
)

Restrict the number of aliases for collection nodes to prevent a Billion laughs attack.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setParseComments
(boolean
- use true to parse comments to the presentation tree (Node)
parseComments
)

Parse comments to the presentation tree (Node).

public LoadSettingsBuilder

Returns:

the builder with the provided value
setSchema
(Schema
to be used for parsing
schema
)

Provide either recommended or custom schema instead of default * org.snakeyaml.engine.v2.schema.CoreSchema These 3 are available org.snakeyaml.engine.v2.schema.FailsafeSchema, org.snakeyaml.engine.v2.schema.JsonSchema, org.snakeyaml.engine.v2.schema.CoreSchema.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setTagConstructors
(Map<Tag, ConstructNode>
- the map from a Tag to its constructor
tagConstructors
)

Provide constructors for the specified tags.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setUseMarks
(boolean
- use false to save resources but use less informative error messages (no line and context)
useMarks
)

Marks are only used for error messages.

public LoadSettingsBuilder

Returns:

the builder with the provided value
setVersionFunction
(UnaryOperator<SpecVersion>
- define the way to manage the YAML version. By default, 1.* versions are accepted and treated as YAML 1.2. Other versions fail to parse (YamlVersionException is thown)
versionFunction
)

Manage YAML directive value which defines the version of the YAML specification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowDuplicateKeysback to summary
private boolean allowDuplicateKeys
allowRecursiveKeysback to summary
private boolean allowRecursiveKeys
bufferSizeback to summary
private Integer bufferSize
codePointLimitback to summary
private int codePointLimit
customPropertiesback to summary
private final Map<SettingKey, Object> customProperties
defaultListback to summary
private IntFunction<List<Object>> defaultList
defaultMapback to summary
private IntFunction<Map<Object, Object>> defaultMap
defaultSetback to summary
private IntFunction<Set<Object>> defaultSet
envConfigback to summary
private Optional<EnvConfig> envConfig
labelback to summary
private String label
maxAliasesForCollectionsback to summary
private int maxAliasesForCollections
parseCommentsback to summary
private boolean parseComments
schemaback to summary
private Schema schema
tagConstructorsback to summary
private Map<Tag, ConstructNode> tagConstructors
useMarksback to summary
private boolean useMarks
versionFunctionback to summary
private UnaryOperator<SpecVersion> versionFunction

Constructor Detail

LoadSettingsBuilderback to summary
pack-priv LoadSettingsBuilder()

Create builder

Method Detail

buildback to summary
public LoadSettings build()

Build immutable LoadSettings

Returns:LoadSettings

immutable LoadSettings

setAllowDuplicateKeysback to summary
public LoadSettingsBuilder setAllowDuplicateKeys(boolean allowDuplicateKeys)

YAML 1.2 does require unique keys. To support the backwards compatibility it is possible to select what should happen when non-unique keys are detected.

Parameters
allowDuplicateKeys:boolean

- if true, then the non-unique keys in a mapping are allowed (last key wins). False by default.

Returns:LoadSettingsBuilder

the builder with the provided value

setAllowRecursiveKeysback to summary
public LoadSettingsBuilder setAllowRecursiveKeys(boolean allowRecursiveKeys)

Allow only non-recursive keys for maps and sets. By default, is it not allowed. Even though YAML allows to use anything as a key, it may cause unexpected issues when loading recursive structures.

Parameters
allowRecursiveKeys:boolean

- true to allow recursive structures as keys

Returns:LoadSettingsBuilder

the builder with the provided value

setBufferSizeback to summary
public LoadSettingsBuilder setBufferSize(Integer bufferSize)

Buffer size for incoming data stream. If the incoming stream is already buffered, then changing the buffer does not improve the performance

Parameters
bufferSize:Integer

- buffer size (in bytes) for input data

Returns:LoadSettingsBuilder

the builder with the provided value

setCodePointLimitback to summary
public LoadSettingsBuilder setCodePointLimit(int codePointLimit)

The max amount of code points for every input YAML document in the stream. Please be aware that byte limit depends on the encoding.

Parameters
codePointLimit:int

- the max allowed size of a single YAML document in a stream

Returns:LoadSettingsBuilder

the builder with the provided value

setCustomPropertyback to summary
public LoadSettingsBuilder setCustomProperty(SettingKey key, Object value)

Provide a custom property to be used later

Parameters
key:SettingKey

- the key

value:Object

- the value behind the key

Returns:LoadSettingsBuilder

the builder with the provided value

setDefaultListback to summary
public LoadSettingsBuilder setDefaultList(IntFunction<List<Object>> defaultList)

Provide default List implementation. ArrayList is used if nothing provided.

Parameters
defaultList:IntFunction<List<Object>>

- specified List implementation (as a function from init size)

Returns:LoadSettingsBuilder

the builder with the provided value

setDefaultMapback to summary
public LoadSettingsBuilder setDefaultMap(IntFunction<Map<Object, Object>> defaultMap)

Provide default Map implementation. LinkedHashMap is used if nothing provided.

Parameters
defaultMap:IntFunction<Map<Object, Object>>

- specified Map implementation (as a function from init size)

Returns:LoadSettingsBuilder

the builder with the provided value

setDefaultSetback to summary
public LoadSettingsBuilder setDefaultSet(IntFunction<Set<Object>> defaultSet)

Provide default Set implementation. LinkedHashSet is used if nothing provided.

Parameters
defaultSet:IntFunction<Set<Object>>

- specified Set implementation (as a function from init size)

Returns:LoadSettingsBuilder

the builder with the provided value

setEnvConfigback to summary
public LoadSettingsBuilder setEnvConfig(Optional<EnvConfig> envConfig)

Define EnvConfig to parse ENV format. If not set explicitly the variable substitution is not applied.

Parameters
envConfig:Optional<EnvConfig>

- non-empty configuration to substitute variables

Returns:LoadSettingsBuilder

the builder with the provided value

See Also
Variable substitution
setLabelback to summary
public LoadSettingsBuilder setLabel(String label)

Label for the input data. Can be used to improve the error message.

Parameters
label:String

- meaningful label to indicate the input source

Returns:LoadSettingsBuilder

the builder with the provided value

setMaxAliasesForCollectionsback to summary
public LoadSettingsBuilder setMaxAliasesForCollections(int maxAliasesForCollections)

Restrict the number of aliases for collection nodes to prevent a Billion laughs attack. The purpose of this setting is to force SnakeYAML to fail before a lot of CPU and memory resources are allocated for the parser. Aliases for scalar nodes do not count because they do not grow exponentially.

Parameters
maxAliasesForCollections:int

- max number of aliases. More than 50 might be very dangerous. Default is 50

Returns:LoadSettingsBuilder

the builder with the provided value

setParseCommentsback to summary
public LoadSettingsBuilder setParseComments(boolean parseComments)

Parse comments to the presentation tree (Node). False by default

Parameters
parseComments:boolean

- use true to parse comments to the presentation tree (Node)

Returns:LoadSettingsBuilder

the builder with the provided value

setSchemaback to summary
public LoadSettingsBuilder setSchema(Schema schema)

Provide either recommended or custom schema instead of default * org.snakeyaml.engine.v2.schema.CoreSchema These 3 are available org.snakeyaml.engine.v2.schema.FailsafeSchema, org.snakeyaml.engine.v2.schema.JsonSchema, org.snakeyaml.engine.v2.schema.CoreSchema.

Parameters
schema:Schema

to be used for parsing

Returns:LoadSettingsBuilder

the builder with the provided value

setTagConstructorsback to summary
public LoadSettingsBuilder setTagConstructors(Map<Tag, ConstructNode> tagConstructors)

Provide constructors for the specified tags.

Parameters
tagConstructors:Map<Tag, ConstructNode>

- the map from a Tag to its constructor

Returns:LoadSettingsBuilder

the builder with the provided value

setUseMarksback to summary
public LoadSettingsBuilder setUseMarks(boolean useMarks)

Marks are only used for error messages. But they require a lot of memory. True by default.

Parameters
useMarks:boolean

- use false to save resources but use less informative error messages (no line and context)

Returns:LoadSettingsBuilder

the builder with the provided value

setVersionFunctionback to summary
public LoadSettingsBuilder setVersionFunction(UnaryOperator<SpecVersion> versionFunction)

Manage YAML directive value which defines the version of the YAML specification. This parser supports YAML 1.2 but it can parse most of YAML 1.1 and YAML 1.0

This function allows to control the version management. For instance if the document contains old version the parser can be adapted to compensate the problem. Or it can fail to indicate that the incoming version is not supported.

Parameters
versionFunction:UnaryOperator<SpecVersion>

- define the way to manage the YAML version. By default, 1.* versions are accepted and treated as YAML 1.2. Other versions fail to parse (YamlVersionException is thown)

Returns:LoadSettingsBuilder

the builder with the provided value