Top Description Fields Constructors Methods
org.yaml.snakeyaml

public Class LoaderOptions

extends Object
Class Inheritance
Imports
org.yaml.snakeyaml.inspector.TagInspector, .UnTrustedTagInspector

Configuration for loading

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private int
private boolean
private int
private int
private boolean
private TagInspector
tagInspector

Secure by default - no custom classes are allowed

private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final boolean

Returns:

when recursive keys are allowed (the document should be trusted)
getAllowRecursiveKeys
()

getter

public final int

Returns:

max code points in the input document
getCodePointLimit
()

getter

public final int

Returns:

show the limit
getMaxAliasesForCollections
()

getter

public final int

Returns:

the limit
getNestingDepthLimit
()

getter

public TagInspector
public final boolean

Returns:

true when duplicate keys in mapping allowed (the latter overrides the former)
isAllowDuplicateKeys
()

getter

public final boolean

Returns:

true when parsing enum case-sensitive
isEnumCaseSensitive
()

getter

public final boolean

Returns:

comments are kept in Node
isProcessComments
()

getter

public final boolean

Returns:

true when wrapped
isWrappedToRootException
()

getter

public void
setAllowDuplicateKeys(boolean
false to reject duplicate mapping keys
allowDuplicateKeys
)

Allow/Reject duplicate map keys in the YAML file.

public void
setAllowRecursiveKeys(boolean
- false to disable recursive keys
allowRecursiveKeys
)

Allow recursive keys for mappings.

public void
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 void
setEnumCaseSensitive(boolean
- true to set enum case-sensitive, false the reverse
enumCaseSensitive
)

Disables or enables case sensitivity during construct enum constant from string value Default is false.

public void
setMaxAliasesForCollections(int
set max allowed value (50 by default)
maxAliasesForCollections
)

Restrict the amount of aliases for collections (sequences and mappings) to avoid https://en.wikipedia.org/wiki/Billion_laughs_attack

public void
setNestingDepthLimit(int
- depth to be accepted (50 by default)
nestingDepthLimit
)

Set max depth of nested collections.

public LoaderOptions

Returns:

applied options
setProcessComments
(boolean
true to process; false to ignore
processComments
)

Set the comment processing.

public void
public void
setWrappedToRootException(boolean
- true to convert runtime exception to YAMLException
wrappedToRootException
)

Wrap runtime exception to YAMLException during parsing or leave them as they are Default is to leave original exceptions

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowDuplicateKeysback to summary
private boolean allowDuplicateKeys
allowRecursiveKeysback to summary
private boolean allowRecursiveKeys
codePointLimitback to summary
private int codePointLimit
enumCaseSensitiveback to summary
private boolean enumCaseSensitive
maxAliasesForCollectionsback to summary
private int maxAliasesForCollections
nestingDepthLimitback to summary
private int nestingDepthLimit
processCommentsback to summary
private boolean processComments
tagInspectorback to summary
private TagInspector tagInspector

Secure by default - no custom classes are allowed

wrappedToRootExceptionback to summary
private boolean wrappedToRootException

Constructor Detail

LoaderOptionsback to summary
public LoaderOptions()

Method Detail

getAllowRecursiveKeysback to summary
public final boolean getAllowRecursiveKeys()

getter

Returns:boolean

when recursive keys are allowed (the document should be trusted)

getCodePointLimitback to summary
public final int getCodePointLimit()

getter

Returns:int

max code points in the input document

getMaxAliasesForCollectionsback to summary
public final int getMaxAliasesForCollections()

getter

Returns:int

show the limit

getNestingDepthLimitback to summary
public final int getNestingDepthLimit()

getter

Returns:int

the limit

getTagInspectorback to summary
public TagInspector getTagInspector()
isAllowDuplicateKeysback to summary
public final boolean isAllowDuplicateKeys()

getter

Returns:boolean

true when duplicate keys in mapping allowed (the latter overrides the former)

isEnumCaseSensitiveback to summary
public final boolean isEnumCaseSensitive()

getter

Returns:boolean

true when parsing enum case-sensitive

isProcessCommentsback to summary
public final boolean isProcessComments()

getter

Returns:boolean

comments are kept in Node

isWrappedToRootExceptionback to summary
public final boolean isWrappedToRootException()

getter

Returns:boolean

true when wrapped

setAllowDuplicateKeysback to summary
public void setAllowDuplicateKeys(boolean allowDuplicateKeys)

Allow/Reject duplicate map keys in the YAML file. Default is to allow. YAML 1.1 is slightly vague around duplicate entries in the YAML file. The best reference is 3.2.1.3. Nodes Comparison where it hints that a duplicate map key is an error. For future reference, YAML spec 1.2 is clear. The keys MUST be unique. 1.3. Relation to JSON

Parameters
allowDuplicateKeys:boolean

false to reject duplicate mapping keys

setAllowRecursiveKeysback to summary
public void setAllowRecursiveKeys(boolean allowRecursiveKeys)

Allow recursive keys for mappings. By default, it is not allowed. This setting only prevents the case when the key is the value. If the key is only a part of the value (the value is a sequence or a mapping) then this case is not recognized and always allowed.

Parameters
allowRecursiveKeys:boolean

- false to disable recursive keys

setCodePointLimitback to summary
public void 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

setEnumCaseSensitiveback to summary
public void setEnumCaseSensitive(boolean enumCaseSensitive)

Disables or enables case sensitivity during construct enum constant from string value Default is false.

Parameters
enumCaseSensitive:boolean

- true to set enum case-sensitive, false the reverse

setMaxAliasesForCollectionsback to summary
public void setMaxAliasesForCollections(int maxAliasesForCollections)

Restrict the amount of aliases for collections (sequences and mappings) to avoid https://en.wikipedia.org/wiki/Billion_laughs_attack

Parameters
maxAliasesForCollections:int

set max allowed value (50 by default)

setNestingDepthLimitback to summary
public void setNestingDepthLimit(int nestingDepthLimit)

Set max depth of nested collections. When the limit is exceeded an exception is thrown. Aliases/Anchors are not counted. This is to prevent a DoS attack

Parameters
nestingDepthLimit:int

- depth to be accepted (50 by default)

setProcessCommentsback to summary
public LoaderOptions setProcessComments(boolean processComments)

Set the comment processing. By default, comments are ignored.

Parameters
processComments:boolean

true to process; false to ignore

Returns:LoaderOptions

applied options

setTagInspectorback to summary
public void setTagInspector(TagInspector tagInspector)
setWrappedToRootExceptionback to summary
public void setWrappedToRootException(boolean wrappedToRootException)

Wrap runtime exception to YAMLException during parsing or leave them as they are Default is to leave original exceptions

Parameters
wrappedToRootException:boolean

- true to convert runtime exception to YAMLException