Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.api

public final Class DumpSettingsBuilder

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, .Objects, .Optional, org.snakeyaml.engine.v2.common.FlowStyle, .NonPrintableStyle, .ScalarStyle, .SpecVersion, org.snakeyaml.engine.v2.emitter.Emitter, org.snakeyaml.engine.v2.exceptions.EmitterException, .YamlEngineException, org.snakeyaml.engine.v2.nodes.Tag, org.snakeyaml.engine.v2.schema.JsonSchema, .Schema, org.snakeyaml.engine.v2.serializer.AnchorGenerator, .NumberAnchorGenerator

Builder pattern implementation for DumpSettings

Field Summary

Modifier and TypeField and Description
private AnchorGenerator
private String
private boolean
pack-priv Map<SettingKey, Object>
private FlowStyle
private ScalarStyle
private boolean
private boolean
private boolean
private Optional<Tag>
private boolean
private int
private boolean
private int
private int
private boolean
private NonPrintableStyle
private Schema
private boolean
private Map<String, String>
private boolean
private int
private Optional<SpecVersion>

Constructor Summary

AccessConstructor and Description
pack-priv
DumpSettingsBuilder()

Create builder

Method Summary

Modifier and TypeMethod and Description
public DumpSettings

Returns:

DumpSettings with the provided values
build
()

Create immutable DumpSettings

public DumpSettingsBuilder

Returns:

the builder with the provided value
setAnchorGenerator
(AnchorGenerator
- specified function to create anchor names
anchorGenerator
)

Define anchor name generator (by default 'id' + number)

public DumpSettingsBuilder

Returns:

the builder with the provided value
setBestLineBreak
(String
- "\r\n" or "\n"
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.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setCanonical
(boolean
- specify if the canonical representation must be used
canonical
)

Enforce canonical representation

public DumpSettingsBuilder

Returns:

the builder with the provided value
setCustomProperty
(SettingKey
- the key
key
,
Object
- the value behind the key
value
)

Custom property is the way to give some runtime parameters to be used during dumping

public DumpSettingsBuilder

Returns:

the builder with the provided value
setDefaultFlowStyle
(FlowStyle
- specify the style
defaultFlowStyle
)

Define flow style

public DumpSettingsBuilder

Returns:

the builder with the provided value
setDefaultScalarStyle
(ScalarStyle
- specify the scalar style
defaultScalarStyle
)

Define default scalar style

public DumpSettingsBuilder

Returns:

the builder with the provided value
setDereferenceAliases
(Boolean
- true to use copies of objects instead of references to the same instance
dereferenceAliases
)

Disable usage of anchors and aliases while serialising an instance.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setDumpComments
(boolean
- true when comments should be dumped (serialised)
dumpComments
)

Set to true to add comments from Nodes to

public DumpSettingsBuilder

Returns:

the builder with the provided value
setExplicitEnd
(boolean
- true if the document end must be explicitly indicated
explicitEnd
)

Add '...' in the end of the document

public DumpSettingsBuilder

Returns:

the builder with the provided value
setExplicitRootTag
(Optional<Tag>
- specify the root tag
explicitRootTag
)

Define root Tag or let the tag to be detected automatically

public DumpSettingsBuilder

Returns:

the builder with the provided value
setExplicitStart
(boolean
- true if the document start must be explicitly indicated
explicitStart
)

Add '---' in the beginning of the document

public DumpSettingsBuilder

Returns:

the builder with the provided value
setIndent
(int
- 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
indent
)

Define the amount of the spaces for the indent in the block flow style.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setIndentWithIndicator
(boolean
- true when indent for sequences is added to general
indentWithIndicator
)

Set to true to add the indent for sequences to the general indent

public DumpSettingsBuilder

Returns:

the builder with the provided value
setIndicatorIndent
(int
- must be non-negative and less than org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT - 1
indicatorIndent
)

It adds the specified indent for sequence indicator in the block flow.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setMaxSimpleKeyLength
(int
- the limit after which the key gets explicit key indicator '?'
maxSimpleKeyLength
)

Define max key length to use simple key (without '?').

public DumpSettingsBuilder

Returns:

the builder with the provided value
setMultiLineFlow
(boolean
- set false to output all values in a single line.
multiLineFlow
)

Use pretty flow style when every value in the flow context gets a separate line.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setNonPrintableStyle
(NonPrintableStyle
- set this to BINARY to force non-printable String to represented as binary (byte array)
nonPrintableStyle
)

When String object contains non-printable characters, they are escaped with \\u or \\x notation.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setSchema
(Schema
- the tag schema
schema
)

Provide either recommended or custom schema instead of default org.snakeyaml.engine.v2.schema.JsonSchema.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setSplitLines
(boolean
- true to split long lines
splitLines
)

Define whether to split long lines

public DumpSettingsBuilder

Returns:

the builder with the provided value
setTagDirective
(Map<String, String>
- the data to create TAG directive
tagDirective
)

Add TAG directive

public DumpSettingsBuilder

Returns:

the builder with the provided value
setUseUnicodeEncoding
(boolean
- true to use Unicode for "Я", false to use "Ч" for the same char (if useUnicodeEncoding is false then all non-ASCII characters are escaped)
useUnicodeEncoding
)

Specify whether to emit non-ASCII printable Unicode characters (emit Unicode char or escape sequence starting with '\\u') The default value is true.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setWidth
(int
- the width
width
)

Set max width for literal scalars.

public DumpSettingsBuilder

Returns:

the builder with the provided value
setYamlDirective
(Optional<SpecVersion>
- the version to be used in the directive
yamlDirective
)

Add YAML directive

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

anchorGeneratorback to summary
private AnchorGenerator anchorGenerator
bestLineBreakback to summary
private String bestLineBreak
canonicalback to summary
private boolean canonical
customPropertiesback to summary
pack-priv Map<SettingKey, Object> customProperties
defaultFlowStyleback to summary
private FlowStyle defaultFlowStyle
defaultScalarStyleback to summary
private ScalarStyle defaultScalarStyle
dereferenceAliasesback to summary
private boolean dereferenceAliases
dumpCommentsback to summary
private boolean dumpComments
explicitEndback to summary
private boolean explicitEnd
explicitRootTagback to summary
private Optional<Tag> explicitRootTag
explicitStartback to summary
private boolean explicitStart
indentback to summary
private int indent
indentWithIndicatorback to summary
private boolean indentWithIndicator
indicatorIndentback to summary
private int indicatorIndent
maxSimpleKeyLengthback to summary
private int maxSimpleKeyLength
multiLineFlowback to summary
private boolean multiLineFlow
nonPrintableStyleback to summary
private NonPrintableStyle nonPrintableStyle
schemaback to summary
private Schema schema
splitLinesback to summary
private boolean splitLines
tagDirectiveback to summary
private Map<String, String> tagDirective
useUnicodeEncodingback to summary
private boolean useUnicodeEncoding
widthback to summary
private int width
yamlDirectiveback to summary
private Optional<SpecVersion> yamlDirective

Constructor Detail

DumpSettingsBuilderback to summary
pack-priv DumpSettingsBuilder()

Create builder

Method Detail

buildback to summary
public DumpSettings build()

Create immutable DumpSettings

Returns:DumpSettings

DumpSettings with the provided values

setAnchorGeneratorback to summary
public DumpSettingsBuilder setAnchorGenerator(AnchorGenerator anchorGenerator)

Define anchor name generator (by default 'id' + number)

Parameters
anchorGenerator:AnchorGenerator

- specified function to create anchor names

Returns:DumpSettingsBuilder

the builder with the provided value

setBestLineBreakback to summary
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:String

- "\r\n" or "\n"

Returns:DumpSettingsBuilder

the builder with the provided value

setCanonicalback to summary
public DumpSettingsBuilder setCanonical(boolean canonical)

Enforce canonical representation

Parameters
canonical:boolean

- specify if the canonical representation must be used

Returns:DumpSettingsBuilder

the builder with the provided value

setCustomPropertyback to summary
public DumpSettingsBuilder setCustomProperty(SettingKey key, Object value)

Custom property is the way to give some runtime parameters to be used during dumping

Parameters
key:SettingKey

- the key

value:Object

- the value behind the key

Returns:DumpSettingsBuilder

the builder with the provided value

setDefaultFlowStyleback to summary
public DumpSettingsBuilder setDefaultFlowStyle(FlowStyle defaultFlowStyle)

Define flow style

Parameters
defaultFlowStyle:FlowStyle

- specify the style

Returns:DumpSettingsBuilder

the builder with the provided value

setDefaultScalarStyleback to summary
public DumpSettingsBuilder setDefaultScalarStyle(ScalarStyle defaultScalarStyle)

Define default scalar style

Parameters
defaultScalarStyle:ScalarStyle

- specify the scalar style

Returns:DumpSettingsBuilder

the builder with the provided value

setDereferenceAliasesback to summary
public DumpSettingsBuilder setDereferenceAliases(Boolean dereferenceAliases)

Disable usage of anchors and aliases while serialising an instance. Recursive objects will not work when they are disabled. (Forces Serializer to skip emitting anchors names, emit Node content instead of Alias, fail with SerializationException if serialized structure is recursive.)

Parameters
dereferenceAliases:Boolean

- true to use copies of objects instead of references to the same instance

Returns:DumpSettingsBuilder

the builder with the provided value

setDumpCommentsback to summary
public DumpSettingsBuilder setDumpComments(boolean dumpComments)

Set to true to add comments from Nodes to

Parameters
dumpComments:boolean

- true when comments should be dumped (serialised)

Returns:DumpSettingsBuilder

the builder with the provided value

setExplicitEndback to summary
public DumpSettingsBuilder setExplicitEnd(boolean explicitEnd)

Add '...' in the end of the document

Parameters
explicitEnd:boolean

- true if the document end must be explicitly indicated

Returns:DumpSettingsBuilder

the builder with the provided value

setExplicitRootTagback to summary
public DumpSettingsBuilder setExplicitRootTag(Optional<Tag> explicitRootTag)

Define root Tag or let the tag to be detected automatically

Parameters
explicitRootTag:Optional<Tag>

- specify the root tag

Returns:DumpSettingsBuilder

the builder with the provided value

setExplicitStartback to summary
public DumpSettingsBuilder setExplicitStart(boolean explicitStart)

Add '---' in the beginning of the document

Parameters
explicitStart:boolean

- true if the document start must be explicitly indicated

Returns:DumpSettingsBuilder

the builder with the provided value

setIndentback to summary
public DumpSettingsBuilder setIndent(int indent)

Define the amount of the spaces for the indent in the block flow style. Default is 2.

Parameters
indent:int

- 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:DumpSettingsBuilder

the builder with the provided value

setIndentWithIndicatorback to summary
public DumpSettingsBuilder setIndentWithIndicator(boolean indentWithIndicator)

Set to true to add the indent for sequences to the general indent

Parameters
indentWithIndicator:boolean

- true when indent for sequences is added to general

Returns:DumpSettingsBuilder

the builder with the provided value

setIndicatorIndentback to summary
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:int

- must be non-negative and less than org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT - 1

Returns:DumpSettingsBuilder

the builder with the provided value

setMaxSimpleKeyLengthback to summary
public DumpSettingsBuilder setMaxSimpleKeyLength(int maxSimpleKeyLength)

Define max key length to use simple key (without '?'). More info

Parameters
maxSimpleKeyLength:int

- the limit after which the key gets explicit key indicator '?'

Returns:DumpSettingsBuilder

the builder with the provided value

setMultiLineFlowback to summary
public DumpSettingsBuilder setMultiLineFlow(boolean multiLineFlow)

Use pretty flow style when every value in the flow context gets a separate line.

Parameters
multiLineFlow:boolean

- set false to output all values in a single line.

Returns:DumpSettingsBuilder

the builder with the provided value

setNonPrintableStyleback to summary
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:NonPrintableStyle

- set this to BINARY to force non-printable String to represented as binary (byte array)

Returns:DumpSettingsBuilder

the builder with the provided value

setSchemaback to summary
public DumpSettingsBuilder setSchema(Schema schema)

Provide either recommended or custom schema instead of default org.snakeyaml.engine.v2.schema.JsonSchema. These 3 are available org.snakeyaml.engine.v2.schema.FailsafeSchema, org.snakeyaml.engine.v2.schema.JsonSchema, org.snakeyaml.engine.v2.schema.CoreSchema.

Parameters
schema:Schema

- the tag schema

Returns:DumpSettingsBuilder

the builder with the provided value

setSplitLinesback to summary
public DumpSettingsBuilder setSplitLines(boolean splitLines)

Define whether to split long lines

Parameters
splitLines:boolean

- true to split long lines

Returns:DumpSettingsBuilder

the builder with the provided value

setTagDirectiveback to summary
public DumpSettingsBuilder setTagDirective(Map<String, String> tagDirective)

Add TAG directive

Parameters
tagDirective:Map<String, String>

- the data to create TAG directive

Returns:DumpSettingsBuilder

the builder with the provided value

setUseUnicodeEncodingback to summary
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:boolean

- true to use Unicode for "Я", false to use "Ч" for the same char (if useUnicodeEncoding is false then all non-ASCII characters are escaped)

Returns:DumpSettingsBuilder

the builder with the provided value

setWidthback to summary
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:int

- the width

Returns:DumpSettingsBuilder

the builder with the provided value

setYamlDirectiveback to summary
public DumpSettingsBuilder setYamlDirective(Optional<SpecVersion> yamlDirective)

Add YAML directive

Parameters
yamlDirective:Optional<SpecVersion>

- the version to be used in the directive

Returns:DumpSettingsBuilder

the builder with the provided value