Package org.snakeyaml.engine.v2.api
Class DumpSettingsBuilder
java.lang.Object
org.snakeyaml.engine.v2.api.DumpSettingsBuilder
Builder pattern implementation for DumpSettings
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AnchorGenerator
private String
private boolean
(package private) Map
<SettingKey, Object> private FlowStyle
private ScalarStyle
private boolean
private boolean
private boolean
private int
private boolean
private int
private int
private boolean
private NonPrintableStyle
private Schema
private boolean
private boolean
private int
private Optional
<SpecVersion> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create immutable DumpSettingssetAnchorGenerator
(AnchorGenerator anchorGenerator) Define anchor name generator (by default 'id' + number)setBestLineBreak
(String bestLineBreak) If the YAML is created for another platform (for instance on Windows to be consumed under Linux) than this setting is used to define the line ending.setCanonical
(boolean canonical) Enforce canonical representationsetCustomProperty
(SettingKey key, Object value) Custom property is the way to give some runtime parameters to be used during dumpingsetDefaultFlowStyle
(FlowStyle defaultFlowStyle) Define flow stylesetDefaultScalarStyle
(ScalarStyle defaultScalarStyle) Define default scalar stylesetDumpComments
(boolean dumpComments) Set to true to add comments from Nodes tosetExplicitEnd
(boolean explicitEnd) Add '...' in the end of the documentsetExplicitRootTag
(Optional<Tag> explicitRootTag) Define rootTag
or let the tag to be detected automaticallysetExplicitStart
(boolean explicitStart) Add '---' in the beginning of the documentsetIndent
(int indent) Define the amount of the spaces for the indent in the block flow style.setIndentWithIndicator
(boolean indentWithIndicator) Set to true to add the indent for sequences to the general indentsetIndicatorIndent
(int indicatorIndent) It adds the specified indent for sequence indicator in the block flow.setMaxSimpleKeyLength
(int maxSimpleKeyLength) Define max key length to use simple key (without '?').setMultiLineFlow
(boolean multiLineFlow) Use pretty flow style when every value in the flow context gets a separate line.setNonPrintableStyle
(NonPrintableStyle nonPrintableStyle) When String object contains non-printable characters, they are escaped with \\u or \\x notation.Provide either recommended or custom schema instead of defaultJsonSchema
.setSplitLines
(boolean splitLines) Define whether to split long linessetTagDirective
(Map<String, String> tagDirective) Add TAG directivesetUseUnicodeEncoding
(boolean useUnicodeEncoding) Specify whether to emit non-ASCII printable Unicode characters (emit Unicode char or escape sequence starting with '\\u') The default value is true.setWidth
(int width) Set max width for literal scalars.setYamlDirective
(Optional<SpecVersion> yamlDirective) Add YAML directive
-
Field Details
-
customProperties
Map<SettingKey,Object> customProperties -
explicitStart
private boolean explicitStart -
explicitEnd
private boolean explicitEnd -
nonPrintableStyle
-
explicitRootTag
-
anchorGenerator
-
yamlDirective
-
tagDirective
-
defaultFlowStyle
-
defaultScalarStyle
-
canonical
private boolean canonical -
multiLineFlow
private boolean multiLineFlow -
useUnicodeEncoding
private boolean useUnicodeEncoding -
indent
private int indent -
indicatorIndent
private int indicatorIndent -
width
private int width -
bestLineBreak
-
splitLines
private boolean splitLines -
maxSimpleKeyLength
private int maxSimpleKeyLength -
indentWithIndicator
private boolean indentWithIndicator -
dumpComments
private boolean dumpComments -
schema
-
-
Constructor Details
-
DumpSettingsBuilder
DumpSettingsBuilder()Create builder
-
-
Method Details
-
setDefaultFlowStyle
Define flow style- Parameters:
defaultFlowStyle
- - specify the style- Returns:
- the builder with the provided value
-
setDefaultScalarStyle
Define default scalar style- Parameters:
defaultScalarStyle
- - specify the scalar style- Returns:
- the builder with the provided value
-
setExplicitStart
Add '---' in the beginning of the document- Parameters:
explicitStart
- - true if the document start must be explicitly indicated- Returns:
- the builder with the provided value
-
setAnchorGenerator
Define anchor name generator (by default 'id' + number)- Parameters:
anchorGenerator
- - specified function to create anchor names- Returns:
- the builder with the provided value
-
setExplicitRootTag
Define rootTag
or let the tag to be detected automatically- Parameters:
explicitRootTag
- - specify the root tag- Returns:
- the builder with the provided value
-
setExplicitEnd
Add '...' in the end of the document- Parameters:
explicitEnd
- - true if the document end must be explicitly indicated- Returns:
- the builder with the provided value
-
setYamlDirective
Add YAML directive- Parameters:
yamlDirective
- - the version to be used in the directive- Returns:
- the builder with the provided value
-
setTagDirective
Add TAG directive- Parameters:
tagDirective
- - the data to create TAG directive- Returns:
- the builder with the provided value
-
setCanonical
Enforce canonical representation- Parameters:
canonical
- - specify if the canonical representation must be used- Returns:
- the builder with the provided value
-
setMultiLineFlow
Use pretty flow style when every value in the flow context gets a separate line.- Parameters:
multiLineFlow
- - set false to output all values in a single line.- Returns:
- the builder with the provided value
-
setUseUnicodeEncoding
Specify whether to emit non-ASCII printable Unicode characters (emit Unicode char or escape sequence starting with '\\u') The default value is true. When set to false then printable non-ASCII characters (Cyrillic, Chinese etc) will be not printed but escaped (to support ASCII terminals)- Parameters:
useUnicodeEncoding
- - true to use Unicode for "Я", false to use "Ч" for the same char (if useUnicodeEncoding is false then all non-ASCII characters are escaped)- Returns:
- the builder with the provided value
-
setIndent
Define the amount of the spaces for the indent in the block flow style. Default is 2.- Parameters:
indent
- - the number of spaces. Must be within the range org.snakeyaml.engine.v2.emitter.Emitter.MIN_INDENT and org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT- Returns:
- the builder with the provided value
-
setIndicatorIndent
It adds the specified indent for sequence indicator in the block flow. Default is 0. For better visual results it should be by 2 less than the indent (which is 2 by default) It is 2 chars less because the first char is '-' and the second char is the space after it.- Parameters:
indicatorIndent
- - must be non-negative and less than org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT - 1- Returns:
- the builder with the provided value
-
setWidth
Set max width for literal scalars. When the scalar representation takes more then the preferred with the scalar will be split into a few lines. The default is 80.- Parameters:
width
- - the width- Returns:
- the builder with the provided value
-
setBestLineBreak
If the YAML is created for another platform (for instance on Windows to be consumed under Linux) than this setting is used to define the line ending. The platform line end is used by default.- Parameters:
bestLineBreak
- - "\r\n" or "\n"- Returns:
- the builder with the provided value
-
setSplitLines
Define whether to split long lines- Parameters:
splitLines
- - true to split long lines- Returns:
- the builder with the provided value
-
setMaxSimpleKeyLength
Define max key length to use simple key (without '?'). More info- Parameters:
maxSimpleKeyLength
- - the limit after which the key gets explicit key indicator '?'- Returns:
- the builder with the provided value
-
setNonPrintableStyle
When String object contains non-printable characters, they are escaped with \\u or \\x notation. Sometimes it is better to transform this data to binary (with the !!binary tag). String objects with printable data are non affected by this setting.- Parameters:
nonPrintableStyle
- - set this to BINARY to force non-printable String to represented as binary (byte array)- Returns:
- the builder with the provided value
-
setCustomProperty
Custom property is the way to give some runtime parameters to be used during dumping- Parameters:
key
- - the keyvalue
- - the value behind the key- Returns:
- the builder with the provided value
-
setIndentWithIndicator
Set to true to add the indent for sequences to the general indent- Parameters:
indentWithIndicator
- - true when indent for sequences is added to general- Returns:
- the builder with the provided value
-
setDumpComments
Set to true to add comments from Nodes to- Parameters:
dumpComments
- - true when comments should be dumped (serialised)- Returns:
- the builder with the provided value
-
setSchema
Provide either recommended or custom schema instead of defaultJsonSchema
. These 3 are availableFailsafeSchema
,JsonSchema
,CoreSchema
.- Parameters:
schema
- - the tag schema- Returns:
- the builder with the provided value
-
build
Create immutable DumpSettings- Returns:
- DumpSettings with the provided values
-