@@ -58,15 +58,22 @@ public enum Feature implements FormatFeature // since 2.9
58
58
59
59
/**
60
60
* Do we try to force so-called canonical output or not.
61
+ * <p>
62
+ * Ignored if you provide your own {@code DumperOptions}.
63
+ * </p>
61
64
*/
62
65
CANONICAL_OUTPUT (false ),
63
66
64
67
/**
65
68
* Options passed to SnakeYAML that determines whether longer textual content
66
69
* gets automatically split into multiple lines or not.
67
- *<p>
68
- * Feature is enabled by default to conform to SnakeYAML defaults as well as
69
- * backwards compatibility with 2.5 and earlier versions.
70
+ * <p>
71
+ * Feature is enabled by default to conform to SnakeYAML defaults as well as
72
+ * backwards compatibility with 2.5 and earlier versions.
73
+ * </p>
74
+ * <p>
75
+ * Ignored if you provide your own {@code DumperOptions}.
76
+ * </p>
70
77
*
71
78
* @since 2.6
72
79
*/
@@ -75,10 +82,11 @@ public enum Feature implements FormatFeature // since 2.9
75
82
/**
76
83
* Whether strings will be rendered without quotes (true) or
77
84
* with quotes (false, default).
78
- *<p>
79
- * Minimized quote usage makes for more human readable output; however, content is
80
- * limited to printable characters according to the rules of
81
- * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
85
+ * <p>
86
+ * Minimized quote usage makes for more human readable output; however, content is
87
+ * limited to printable characters according to the rules of
88
+ * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
89
+ * </p>
82
90
*
83
91
* @since 2.7
84
92
*/
@@ -87,10 +95,11 @@ public enum Feature implements FormatFeature // since 2.9
87
95
/**
88
96
* Whether numbers stored as strings will be rendered with quotes (true) or
89
97
* without quotes (false, default) when MINIMIZE_QUOTES is enabled.
90
- *<p>
91
- * Minimized quote usage makes for more human readable output; however, content is
92
- * limited to printable characters according to the rules of
93
- * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
98
+ * <p>
99
+ * Minimized quote usage makes for more human readable output; however, content is
100
+ * limited to printable characters according to the rules of
101
+ * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
102
+ * </p>
94
103
*
95
104
* @since 2.8.2
96
105
*/
@@ -101,8 +110,9 @@ public enum Feature implements FormatFeature // since 2.9
101
110
* <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>
102
111
* should be used. This automatically enabled when {@link #MINIMIZE_QUOTES} is set.
103
112
* <p>
104
- * The content of such strings is limited to printable characters according to the rules of
105
- * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
113
+ * The content of such strings is limited to printable characters according to the rules of
114
+ * <a href="http://www.yaml.org/spec/1.2/spec.html#style/block/literal">literal block style</a>.
115
+ * </p>
106
116
*
107
117
* @since 2.9
108
118
*/
@@ -111,17 +121,25 @@ public enum Feature implements FormatFeature // since 2.9
111
121
/**
112
122
* Feature enabling of which adds indentation for array entry generation
113
123
* (default indentation being 2 spaces).
114
- *<p>
115
- * Default value is {@code false} for backwards compatibility
124
+ * <p>
125
+ * Default value is {@code false} for backwards compatibility
126
+ * </p>
127
+ * <p>
128
+ * Ignored if you provide your own {@code DumperOptions}.
129
+ * </p>
116
130
*
117
131
* @since 2.9
118
132
*/
119
133
INDENT_ARRAYS (false ),
120
134
/**
121
135
* Feature enabling of which adds indentation with indicator for array entry generation
122
136
* (default indentation being 2 spaces).
123
- *<p>
124
- * Default value is {@code false} for backwards compatibility
137
+ * <p>
138
+ * Default value is {@code false} for backwards compatibility
139
+ * </p>
140
+ * <p>
141
+ * Ignored if you provide your own {@code DumperOptions}.
142
+ * </p>
125
143
*
126
144
* @since 2.12
127
145
*/
@@ -132,7 +150,11 @@ public enum Feature implements FormatFeature // since 2.9
132
150
* serialization should be same as what the default is for current platform.
133
151
* If disabled, Unix linefeed ({@code \n}) will be used.
134
152
* <p>
135
- * Default value is {@code false} for backwards compatibility.
153
+ * Default value is {@code false} for backwards compatibility
154
+ * </p>
155
+ * <p>
156
+ * Ignored if you provide your own {@code DumperOptions}.
157
+ * </p>
136
158
*
137
159
* @since 2.9.6
138
160
*/
@@ -144,8 +166,12 @@ public enum Feature implements FormatFeature // since 2.9
144
166
* If disabled, the max key length is left as 128 characters: longer names
145
167
* are truncated. If enabled, limit is raised to 1024 characters.
146
168
* <p>
147
- * Default value is {@code false} for backwards-compatibility (same as behavior
148
- * before this feature was added).
169
+ * Default value is {@code false} for backwards-compatibility (same as behavior
170
+ * before this feature was added).
171
+ * </p>
172
+ * <p>
173
+ * Ignored if you provide your own {@code DumperOptions}.
174
+ * </p>
149
175
*
150
176
* @since 2.14
151
177
*/
@@ -283,6 +309,30 @@ public YAMLGenerator(IOContext ctxt, int jsonFeatures, int yamlFeatures,
283
309
_emitStartDocument ();
284
310
}
285
311
312
+ /**
313
+ * @since 2.14
314
+ */
315
+ public YAMLGenerator (IOContext ctxt , int jsonFeatures , int yamlFeatures ,
316
+ StringQuotingChecker quotingChecker ,
317
+ ObjectCodec codec , Writer out ,
318
+ org .yaml .snakeyaml .DumperOptions dumperOptions )
319
+ throws IOException
320
+ {
321
+ super (jsonFeatures , codec );
322
+ _ioContext = ctxt ;
323
+ _formatFeatures = yamlFeatures ;
324
+ _quotingChecker = (quotingChecker == null )
325
+ ? StringQuotingChecker .Default .instance () : quotingChecker ;
326
+ _writer = out ;
327
+ _docVersion = dumperOptions .getVersion ();
328
+ _outputOptions = dumperOptions ;
329
+
330
+ _emitter = new Emitter (_writer , _outputOptions );
331
+ // should we start output now, or try to defer?
332
+ _emit (new StreamStartEvent (null , null ));
333
+ _emitStartDocument ();
334
+ }
335
+
286
336
@ Deprecated // since 2.12
287
337
public YAMLGenerator (IOContext ctxt , int jsonFeatures , int yamlFeatures ,
288
338
ObjectCodec codec , Writer out ,
0 commit comments