Package org.snakeyaml.engine.v2.api
Class DumpSettingsBuilder
- java.lang.Object
-
- org.snakeyaml.engine.v2.api.DumpSettingsBuilder
-
public final class DumpSettingsBuilder extends Object
Builder pattern implementation for DumpSettings
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DumpSettingsbuild()Create immutable DumpSettingsDumpSettingsBuildersetAnchorGenerator(AnchorGenerator anchorGenerator)Define anchor name generator (by default 'id' + number)DumpSettingsBuildersetBestLineBreak(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.DumpSettingsBuildersetCanonical(boolean canonical)Enforce canonical representationDumpSettingsBuildersetCustomProperty(SettingKey key, Object value)DumpSettingsBuildersetDefaultFlowStyle(FlowStyle defaultFlowStyle)Define flow styleDumpSettingsBuildersetDefaultScalarStyle(ScalarStyle defaultScalarStyle)Define default scalar styleDumpSettingsBuildersetExplicitEnd(boolean explicitEnd)Add '...' in the end of the documentDumpSettingsBuildersetExplicitRootTag(Optional<Tag> explicitRootTag)Define rootTagor let the tag to be detected automaticallyDumpSettingsBuildersetExplicitStart(boolean explicitStart)Add '---' in the beginning of the documentDumpSettingsBuildersetIndent(int indent)Define the amount of the spaces for the indent in the block flow style.DumpSettingsBuildersetIndentWithIndicator(boolean indentWithIndicator)Set to true to add the indent for sequences to the general indentDumpSettingsBuildersetIndicatorIndent(int indicatorIndent)It adds the specified indent for sequence indicator in the block flow.DumpSettingsBuildersetMaxSimpleKeyLength(int maxSimpleKeyLength)Define max key length to use simple key (without '?') More info https://yaml.org/spec/1.2/spec.html#id2798057DumpSettingsBuildersetMultiLineFlow(boolean multiLineFlow)Use pretty flow style when every value in the flow context gets a separate line.DumpSettingsBuildersetNonPrintableStyle(NonPrintableStyle nonPrintableStyle)When String object contains non-printable characters, they are escaped with \\u or \\x notation.DumpSettingsBuildersetScalarResolver(ScalarResolver scalarResolver)DefineScalarResolveror use JSON resolver by default.DumpSettingsBuildersetSplitLines(boolean splitLines)Define whether to split long linesDumpSettingsBuildersetTagDirective(Map<String,String> tagDirective)Add TAG directive (http://yaml.org/spec/1.2/spec.html#id2782090)DumpSettingsBuildersetUseUnicodeEncoding(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.DumpSettingsBuildersetWidth(int width)Set max width for literal scalars.DumpSettingsBuildersetYamlDirective(Optional<SpecVersion> yamlDirective)Add YAML directive (http://yaml.org/spec/1.2/spec.html#id2782090)
-
-
-
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
-
setScalarResolver
public DumpSettingsBuilder setScalarResolver(ScalarResolver scalarResolver)
DefineScalarResolveror use JSON resolver by default. Do we need this method ?- Parameters:
scalarResolver- - specify the scalar resolver- Returns:
- the builder with the provided value
-
setExplicitRootTag
public DumpSettingsBuilder setExplicitRootTag(Optional<Tag> explicitRootTag)
Define rootTagor 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(Optional<SpecVersion> yamlDirective)
Add YAML directive (http://yaml.org/spec/1.2/spec.html#id2782090)- Parameters:
yamlDirective- - the version to be used in the directive- Returns:
- the builder with the provided value
-
setTagDirective
public DumpSettingsBuilder setTagDirective(Map<String,String> tagDirective)
Add TAG directive (http://yaml.org/spec/1.2/spec.html#id2782090)- 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(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 https://yaml.org/spec/1.2/spec.html#id2798057- 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, Object 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
-
build
public DumpSettings build()
Create immutable DumpSettings- Returns:
- DumpSettings with the provided values
-
-