Package org.yaml.snakeyaml
Class LoaderOptions
- java.lang.Object
-
- org.yaml.snakeyaml.LoaderOptions
-
public class LoaderOptions extends Object
Configuration for loading
-
-
Constructor Summary
Constructors Constructor Description LoaderOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetAllowRecursiveKeys()getterintgetCodePointLimit()getterintgetMaxAliasesForCollections()getterintgetNestingDepthLimit()getterorg.yaml.snakeyaml.inspector.TagInspectorgetTagInspector()booleanisAllowDuplicateKeys()getterbooleanisEnumCaseSensitive()getterbooleanisProcessComments()getterbooleanisWrappedToRootException()gettervoidsetAllowDuplicateKeys(boolean allowDuplicateKeys)Allow/Reject duplicate map keys in the YAML file.voidsetAllowRecursiveKeys(boolean allowRecursiveKeys)Allow recursive keys for mappings.voidsetCodePointLimit(int codePointLimit)The max amount of code points in the input YAML document.voidsetEnumCaseSensitive(boolean enumCaseSensitive)Disables or enables case sensitivity during construct enum constant from string value Default is false.voidsetMaxAliasesForCollections(int maxAliasesForCollections)Restrict the amount of aliases for collections (sequences and mappings) to avoid https://en.wikipedia.org/wiki/Billion_laughs_attackvoidsetNestingDepthLimit(int nestingDepthLimit)Set max depth of nested collections.LoaderOptionssetProcessComments(boolean processComments)Set the comment processing.voidsetTagInspector(org.yaml.snakeyaml.inspector.TagInspector tagInspector)voidsetWrappedToRootException(boolean wrappedToRootException)Wrap runtime exception to YAMLException during parsing or leave them as they are Default is to leave original exceptions
-
-
-
Method Detail
-
isAllowDuplicateKeys
public final boolean isAllowDuplicateKeys()
getter- Returns:
- true when duplicate keys in mapping allowed (the latter overrides the former)
-
setAllowDuplicateKeys
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- false to reject duplicate mapping keys
-
isWrappedToRootException
public final boolean isWrappedToRootException()
getter- Returns:
- true when wrapped
-
setWrappedToRootException
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- - true to convert runtime exception to YAMLException
-
getMaxAliasesForCollections
public final int getMaxAliasesForCollections()
getter- Returns:
- show the limit
-
setMaxAliasesForCollections
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- set max allowed value (50 by default)
-
getAllowRecursiveKeys
public final boolean getAllowRecursiveKeys()
getter- Returns:
- when recursive keys are allowed (the document should be trusted)
-
setAllowRecursiveKeys
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- - false to disable recursive keys
-
isProcessComments
public final boolean isProcessComments()
getter- Returns:
- comments are kept in Node
-
setProcessComments
public LoaderOptions setProcessComments(boolean processComments)
Set the comment processing. By default, comments are ignored.- Parameters:
processComments-trueto process;falseto ignore- Returns:
- applied options
-
isEnumCaseSensitive
public final boolean isEnumCaseSensitive()
getter- Returns:
- true when parsing enum case-sensitive
-
setEnumCaseSensitive
public void setEnumCaseSensitive(boolean enumCaseSensitive)
Disables or enables case sensitivity during construct enum constant from string value Default is false.- Parameters:
enumCaseSensitive- - true to set enum case-sensitive, false the reverse
-
getNestingDepthLimit
public final int getNestingDepthLimit()
getter- Returns:
- the limit
-
setNestingDepthLimit
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- - depth to be accepted (50 by default)
-
getCodePointLimit
public final int getCodePointLimit()
getter- Returns:
- max code points in the input document
-
setCodePointLimit
public void setCodePointLimit(int codePointLimit)
The max amount of code points in the input YAML document. Please be aware that byte limit depends on the encoding.- Parameters:
codePointLimit- - the max allowed size of the YAML data
-
getTagInspector
public org.yaml.snakeyaml.inspector.TagInspector getTagInspector()
-
setTagInspector
public void setTagInspector(org.yaml.snakeyaml.inspector.TagInspector tagInspector)
-
-