Package org.snakeyaml.engine.v2.api
Class DumpSettingsBuilder
- java.lang.Object
-
- org.snakeyaml.engine.v2.api.DumpSettingsBuilder
-
public final class DumpSettingsBuilder extends java.lang.Object
Builder pattern implementation for DumpSettings
-
-
Field Summary
Fields Modifier and Type Field Description private AnchorGenerator
anchorGenerator
private java.lang.String
bestLineBreak
private boolean
canonical
(package private) java.util.Map<SettingKey,java.lang.Object>
customProperties
private FlowStyle
defaultFlowStyle
private ScalarStyle
defaultScalarStyle
private boolean
dumpComments
private boolean
explicitEnd
private java.util.Optional<Tag>
explicitRootTag
private boolean
explicitStart
private int
indent
private boolean
indentWithIndicator
private int
indicatorIndent
private int
maxSimpleKeyLength
private boolean
multiLineFlow
private NonPrintableStyle
nonPrintableStyle
private Schema
schema
private boolean
splitLines
private java.util.Map<java.lang.String,java.lang.String>
tagDirective
private boolean
useUnicodeEncoding
private int
width
private java.util.Optional<SpecVersion>
yamlDirective
-
Constructor Summary
Constructors Constructor Description DumpSettingsBuilder()
Create builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DumpSettings
build()
Create immutable DumpSettingsDumpSettingsBuilder
setAnchorGenerator(AnchorGenerator anchorGenerator)
Define anchor name generator (by default 'id' + number)DumpSettingsBuilder
setBestLineBreak(java.lang.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.DumpSettingsBuilder
setCanonical(boolean canonical)
Enforce canonical representationDumpSettingsBuilder
setCustomProperty(SettingKey key, java.lang.Object value)
Custom property is the way to give some runtime parameters to be used during dumpingDumpSettingsBuilder
setDefaultFlowStyle(FlowStyle defaultFlowStyle)
Define flow styleDumpSettingsBuilder
setDefaultScalarStyle(ScalarStyle defaultScalarStyle)
Define default scalar styleDumpSettingsBuilder
setDumpComments(boolean dumpComments)
Set to true to add comments from Nodes toDumpSettingsBuilder
setExplicitEnd(boolean explicitEnd)
Add '...' in the end of the documentDumpSettingsBuilder
setExplicitRootTag(java.util.Optional<Tag> explicitRootTag)
Define rootTag
or let the tag to be detected automaticallyDumpSettingsBuilder
setExplicitStart(boolean explicitStart)
Add '---' in the beginning of the documentDumpSettingsBuilder
setIndent(int indent)
Define the amount of the spaces for the indent in the block flow style.DumpSettingsBuilder
setIndentWithIndicator(boolean indentWithIndicator)
Set to true to add the indent for sequences to the general indentDumpSettingsBuilder
setIndicatorIndent(int indicatorIndent)
It adds the specified indent for sequence indicator in the block flow.DumpSettingsBuilder
setMaxSimpleKeyLength(int maxSimpleKeyLength)
Define max key length to use simple key (without '?').DumpSettingsBuilder
setMultiLineFlow(boolean multiLineFlow)
Use pretty flow style when every value in the flow context gets a separate line.DumpSettingsBuilder
setNonPrintableStyle(NonPrintableStyle nonPrintableStyle)
When String object contains non-printable characters, they are escaped with \\u or \\x notation.DumpSettingsBuilder
setSchema(Schema schema)
Provide either recommended or custom schema instead of defaultJsonSchema
.DumpSettingsBuilder
setSplitLines(boolean splitLines)
Define whether to split long linesDumpSettingsBuilder
setTagDirective(java.util.Map<java.lang.String,java.lang.String> tagDirective)
Add TAG directiveDumpSettingsBuilder
setUseUnicodeEncoding(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.DumpSettingsBuilder
setWidth(int width)
Set max width for literal scalars.DumpSettingsBuilder
setYamlDirective(java.util.Optional<SpecVersion> yamlDirective)
Add YAML directive
-
-
-
Field Detail
-
customProperties
java.util.Map<SettingKey,java.lang.Object> customProperties
-
explicitStart
private boolean explicitStart
-
explicitEnd
private boolean explicitEnd
-
nonPrintableStyle
private NonPrintableStyle nonPrintableStyle
-
explicitRootTag
private java.util.Optional<Tag> explicitRootTag
-
anchorGenerator
private AnchorGenerator anchorGenerator
-
yamlDirective
private java.util.Optional<SpecVersion> yamlDirective
-
tagDirective
private java.util.Map<java.lang.String,java.lang.String> tagDirective
-
defaultFlowStyle
private FlowStyle defaultFlowStyle
-
defaultScalarStyle
private ScalarStyle 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
private java.lang.String bestLineBreak
-
splitLines
private boolean splitLines
-
maxSimpleKeyLength
private int maxSimpleKeyLength
-
indentWithIndicator
private boolean indentWithIndicator
-
dumpComments
private boolean dumpComments
-
schema
private Schema schema
-
-
Method Detail
-
setDefaultFlowStyle
public DumpSettingsBuilder setDefaultFlowStyle(FlowStyle defaultFlowStyle)
Define flow style- Parameters:
defaultFlowStyle
- - specify the style- Returns:
- the builder with the provided value
-
setDefaultScalarStyle
public DumpSettingsBuilder setDefaultScalarStyle(ScalarStyle defaultScalarStyle)
Define default scalar style- Parameters:
defaultScalarStyle
- - specify the scalar style- Returns:
- the builder with the provided value
-
setExplicitStart
public DumpSettingsBuilder setExplicitStart(boolean explicitStart)
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
public DumpSettingsBuilder setAnchorGenerator(AnchorGenerator anchorGenerator)
Define anchor name generator (by default 'id' + number)- Parameters:
anchorGenerator
- - specified function to create anchor names- Returns:
- the builder with the provided value
-
setExplicitRootTag
public DumpSettingsBuilder setExplicitRootTag(java.util.Optional<Tag> explicitRootTag)
Define rootTag
or let the tag to be detected automatically- Parameters:
explicitRootTag
- - specify the root tag- Returns:
- the builder with the provided value
-
setExplicitEnd
public DumpSettingsBuilder setExplicitEnd(boolean explicitEnd)
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
public DumpSettingsBuilder setYamlDirective(java.util.Optional<SpecVersion> yamlDirective)
Add YAML directive- Parameters:
yamlDirective
- - the version to be used in the directive- Returns:
- the builder with the provided value
-
setTagDirective
public DumpSettingsBuilder setTagDirective(java.util.Map<java.lang.String,java.lang.String> tagDirective)
Add TAG directive- Parameters:
tagDirective
- - the data to create TAG directive- Returns:
- the builder with the provided value
-
setCanonical
public DumpSettingsBuilder setCanonical(boolean canonical)
Enforce canonical representation- Parameters:
canonical
- - specify if the canonical representation must be used- Returns:
- the builder with the provided value
-
setMultiLineFlow
public DumpSettingsBuilder setMultiLineFlow(boolean multiLineFlow)
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
public DumpSettingsBuilder setUseUnicodeEncoding(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. 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
public DumpSettingsBuilder setIndent(int indent)
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
public DumpSettingsBuilder setIndicatorIndent(int indicatorIndent)
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
public DumpSettingsBuilder setWidth(int width)
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
public DumpSettingsBuilder setBestLineBreak(java.lang.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. The platform line end is used by default.- Parameters:
bestLineBreak
- - "\r\n" or "\n"- Returns:
- the builder with the provided value
-
setSplitLines
public DumpSettingsBuilder setSplitLines(boolean splitLines)
Define whether to split long lines- Parameters:
splitLines
- - true to split long lines- Returns:
- the builder with the provided value
-
setMaxSimpleKeyLength
public DumpSettingsBuilder setMaxSimpleKeyLength(int maxSimpleKeyLength)
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
public DumpSettingsBuilder setNonPrintableStyle(NonPrintableStyle nonPrintableStyle)
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
public DumpSettingsBuilder setCustomProperty(SettingKey key, java.lang.Object value)
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
public DumpSettingsBuilder setIndentWithIndicator(boolean indentWithIndicator)
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
public DumpSettingsBuilder setDumpComments(boolean dumpComments)
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
public DumpSettingsBuilder setSchema(Schema schema)
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
public DumpSettings build()
Create immutable DumpSettings- Returns:
- DumpSettings with the provided values
-
-