Package org.yaml.snakeyaml
Class DumperOptions
- java.lang.Object
-
- org.yaml.snakeyaml.DumperOptions
-
public class DumperOptions extends Object
Configuration for serialisation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDumperOptions.FlowStyleBlock styles use indentation to denote nesting and scope within the document.static classDumperOptions.LineBreakPlatform dependent line break.static classDumperOptions.NonPrintableStylethe way to serialize non-printablestatic classDumperOptions.ScalarStyleYAML provides a rich set of scalar styles.static classDumperOptions.VersionSpecification version.
-
Constructor Summary
Constructors Constructor Description DumperOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnchorGeneratorgetAnchorGenerator()getterDumperOptions.FlowStylegetDefaultFlowStyle()getterDumperOptions.ScalarStylegetDefaultScalarStyle()getterintgetIndent()getterbooleangetIndentWithIndicator()intgetIndicatorIndent()DumperOptions.LineBreakgetLineBreak()getterintgetMaxSimpleKeyLength()DumperOptions.NonPrintableStylegetNonPrintableStyle()booleangetSplitLines()getterMap<String,String>getTags()getterTimeZonegetTimeZone()getterDumperOptions.VersiongetVersion()getterintgetWidth()getterbooleanisAllowReadOnlyProperties()Report whether read-only JavaBean properties (the ones without setters) should be included in the YAML documentbooleanisAllowUnicode()getterbooleanisCanonical()getterbooleanisExplicitEnd()getterbooleanisExplicitStart()getterbooleanisPrettyFlow()getterbooleanisProcessComments()gettervoidsetAllowReadOnlyProperties(boolean allowReadOnlyProperties)Set to true to include read-only JavaBean properties (the ones without setters) in the YAML document.voidsetAllowUnicode(boolean allowUnicode)Specify whether to emit non-ASCII printable Unicode characters.voidsetAnchorGenerator(AnchorGenerator anchorGenerator)Provide a custom generatorvoidsetCanonical(boolean canonical)Force the emitter to produce a canonical YAML document.voidsetDefaultFlowStyle(DumperOptions.FlowStyle defaultFlowStyle)settervoidsetDefaultScalarStyle(DumperOptions.ScalarStyle defaultStyle)Set default style for scalars.voidsetExplicitEnd(boolean explicitEnd)setter - require explicit '...'voidsetExplicitStart(boolean explicitStart)setter - require explicit '...'voidsetIndent(int indent)Define indentation.voidsetIndentWithIndicator(boolean indentWithIndicator)Set to true to add the indent for sequences to the general indentvoidsetIndicatorIndent(int indicatorIndent)Set number of white spaces to use for the sequence indicator '-'voidsetLineBreak(DumperOptions.LineBreak lineBreak)Specify the line break to separate the lines.voidsetMaxSimpleKeyLength(int maxSimpleKeyLength)Define max key length to use simple key (without '?') More info https://yaml.org/spec/1.1/#id934537voidsetNonPrintableStyle(DumperOptions.NonPrintableStyle style)When String contains non-printable characters SnakeYAML convert it to binary data with the !!binary tag.voidsetPrettyFlow(boolean prettyFlow)Force the emitter to produce a pretty YAML document when using the flow style.voidsetProcessComments(boolean processComments)Set the comment processing.voidsetSplitLines(boolean splitLines)Specify whether to split lines exceeding preferred width for scalars.voidsetTags(Map<String,String> tags)settervoidsetTimeZone(TimeZone timeZone)Set the timezone to be used for Date.voidsetVersion(DumperOptions.Version version)Of no use - it is better not to include YAML version as the directivevoidsetWidth(int bestWidth)Specify the preferred width to emit scalars.
-
-
-
Method Detail
-
isAllowUnicode
public boolean isAllowUnicode()
getter- Returns:
- false when non-ASCII is escaped
-
setAllowUnicode
public void setAllowUnicode(boolean allowUnicode)
Specify whether to emit non-ASCII printable Unicode characters. 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:
allowUnicode- if allowUnicode is false then all non-ASCII characters are escaped
-
getDefaultScalarStyle
public DumperOptions.ScalarStyle getDefaultScalarStyle()
getter- Returns:
- scalar style
-
setDefaultScalarStyle
public void setDefaultScalarStyle(DumperOptions.ScalarStyle defaultStyle)
Set default style for scalars. See YAML 1.1 specification, 2.3 Scalars (http://yaml.org/spec/1.1/#id858081)- Parameters:
defaultStyle- set the style for all scalars
-
setIndent
public void setIndent(int indent)
Define indentation. Must be within the limits (1-10)- Parameters:
indent- number of spaces to serve as indentation
-
getIndent
public int getIndent()
getter- Returns:
- indent
-
setIndicatorIndent
public void setIndicatorIndent(int indicatorIndent)
Set number of white spaces to use for the sequence indicator '-'- Parameters:
indicatorIndent- value to be used as indent
-
getIndicatorIndent
public int getIndicatorIndent()
-
getIndentWithIndicator
public boolean getIndentWithIndicator()
-
setIndentWithIndicator
public void 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
-
setVersion
public void setVersion(DumperOptions.Version version)
Of no use - it is better not to include YAML version as the directive- Parameters:
version- 1.0 or 1.1
-
getVersion
public DumperOptions.Version getVersion()
getter- Returns:
- the expected version
-
setCanonical
public void setCanonical(boolean canonical)
Force the emitter to produce a canonical YAML document.- Parameters:
canonical- true produce canonical YAML document
-
isCanonical
public boolean isCanonical()
getter- Returns:
- true when well established format should be dumped
-
setPrettyFlow
public void setPrettyFlow(boolean prettyFlow)
Force the emitter to produce a pretty YAML document when using the flow style.- Parameters:
prettyFlow- true produce pretty flow YAML document
-
isPrettyFlow
public boolean isPrettyFlow()
getter- Returns:
- true for pretty style
-
setWidth
public void setWidth(int bestWidth)
Specify the preferred width to emit 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:
bestWidth- the preferred width for scalars.
-
getWidth
public int getWidth()
getter- Returns:
- the preferred width for scalars
-
setSplitLines
public void setSplitLines(boolean splitLines)
Specify whether to split lines exceeding preferred width for scalars. The default is true.- Parameters:
splitLines- whether to split lines exceeding preferred width for scalars.
-
getSplitLines
public boolean getSplitLines()
getter- Returns:
- true when to split lines exceeding preferred width for scalars
-
getLineBreak
public DumperOptions.LineBreak getLineBreak()
getter- Returns:
- line break to separate lines
-
setDefaultFlowStyle
public void setDefaultFlowStyle(DumperOptions.FlowStyle defaultFlowStyle)
setter- Parameters:
defaultFlowStyle- - enum for the flow style
-
getDefaultFlowStyle
public DumperOptions.FlowStyle getDefaultFlowStyle()
getter- Returns:
- flow style for collections
-
setLineBreak
public void setLineBreak(DumperOptions.LineBreak lineBreak)
Specify the line break to separate the lines. It is platform specific: Windows - "\r\n", old MacOS - "\r", Unix - "\n". The default value is the one for Unix.- Parameters:
lineBreak- to be used for the input
-
isExplicitStart
public boolean isExplicitStart()
getter- Returns:
- true when '---' must be printed
-
setExplicitStart
public void setExplicitStart(boolean explicitStart)
setter - require explicit '...'- Parameters:
explicitStart- - true to emit '---'
-
isExplicitEnd
public boolean isExplicitEnd()
getter- Returns:
- true when '...' must be printed
-
setExplicitEnd
public void setExplicitEnd(boolean explicitEnd)
setter - require explicit '...'- Parameters:
explicitEnd- - true to emit '...'
-
setTags
public void setTags(Map<String,String> tags)
setter- Parameters:
tags- - tag directives for the YAML document
-
isAllowReadOnlyProperties
public boolean isAllowReadOnlyProperties()
Report whether read-only JavaBean properties (the ones without setters) should be included in the YAML document- Returns:
- false when read-only JavaBean properties are not emitted
-
setAllowReadOnlyProperties
public void setAllowReadOnlyProperties(boolean allowReadOnlyProperties)
Set to true to include read-only JavaBean properties (the ones without setters) in the YAML document. By default these properties are not included to be able to parse later the same JavaBean.- Parameters:
allowReadOnlyProperties- - true to dump read-only JavaBean properties
-
getTimeZone
public TimeZone getTimeZone()
getter- Returns:
- timezone to be used to emit Date
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
Set the timezone to be used for Date. If set tonullUTC is used.- Parameters:
timeZone- for created Dates or null to use UTC
-
getAnchorGenerator
public AnchorGenerator getAnchorGenerator()
getter- Returns:
- generator to create anchor names
-
setAnchorGenerator
public void setAnchorGenerator(AnchorGenerator anchorGenerator)
Provide a custom generator- Parameters:
anchorGenerator- - the way to create custom anchors
-
getMaxSimpleKeyLength
public int getMaxSimpleKeyLength()
-
setMaxSimpleKeyLength
public void setMaxSimpleKeyLength(int maxSimpleKeyLength)
Define max key length to use simple key (without '?') More info https://yaml.org/spec/1.1/#id934537- Parameters:
maxSimpleKeyLength- - the limit after which the key gets explicit key indicator '?'
-
setProcessComments
public void setProcessComments(boolean processComments)
Set the comment processing. By default, comments are ignored.- Parameters:
processComments-trueto process;falseto ignore
-
isProcessComments
public boolean isProcessComments()
getter- Returns:
- true when comments are not ignored and can be used after composing a Node
-
getNonPrintableStyle
public DumperOptions.NonPrintableStyle getNonPrintableStyle()
-
setNonPrintableStyle
public void setNonPrintableStyle(DumperOptions.NonPrintableStyle style)
When String contains non-printable characters SnakeYAML convert it to binary data with the !!binary tag. Set this to ESCAPE to keep the !!str tag and escape the non-printable chars with \\x or \\u- Parameters:
style- ESCAPE to force SnakeYAML to keep !!str tag for non-printable data
-
-