@@ -105,13 +105,22 @@ public enum Feature implements FormatFeature
105
105
*/
106
106
LITERAL_BLOCK_STYLE (false ),
107
107
108
+ /**
109
+ * Option passed to SnakeYAML that determines if the line breaks used for
110
+ * serialization should be same as what the default is for current platform.
111
+ * If disabled, Unix linefeed ({@code \n}) will be used.
112
+ * <p>
113
+ * Default value is `false` for backwards compatibility.
114
+ */
115
+ USE_PLATFORM_LINE_BREAKS (false ),
116
+
108
117
/**
109
118
* Feature enabling of which adds indentation for array entry generation
110
119
* (default indentation being 2 spaces).
111
120
*<p>
112
121
* Default value is `false` for backwards compatibility
113
122
*/
114
- INDENT_ARRAYS (false )
123
+ INDENT_ARRAYS (false ),
115
124
;
116
125
117
126
protected final boolean _defaultState ;
@@ -146,9 +155,9 @@ private Feature(boolean defaultState) {
146
155
}
147
156
148
157
/*
149
- /**********************************************************
158
+ /**********************************************************************
150
159
/* Internal constants
151
- /**********************************************************
160
+ /**********************************************************************
152
161
*/
153
162
154
163
protected final static long MIN_INT_AS_LONG = (long ) Integer .MIN_VALUE ;
@@ -157,9 +166,9 @@ private Feature(boolean defaultState) {
157
166
protected final static String TAG_BINARY = Tag .BINARY .toString ();
158
167
159
168
/*
160
- /**********************************************************
169
+ /**********************************************************************
161
170
/* Configuration
162
- /**********************************************************
171
+ /**********************************************************************
163
172
*/
164
173
165
174
final protected IOContext _ioContext ;
@@ -192,9 +201,9 @@ private Feature(boolean defaultState) {
192
201
private final static ScalarStyle STYLE_PLAIN = ScalarStyle .PLAIN ;
193
202
194
203
/*
195
- /**********************************************************
204
+ /**********************************************************************
196
205
/* Output state
197
- /**********************************************************
206
+ /**********************************************************************
198
207
*/
199
208
200
209
protected Emitter _emitter ;
@@ -212,9 +221,9 @@ private Feature(boolean defaultState) {
212
221
protected String _typeId ;
213
222
214
223
/*
215
- /**********************************************************
224
+ /**********************************************************************
216
225
/* Life-cycle
217
- /**********************************************************
226
+ /**********************************************************************
218
227
*/
219
228
220
229
public YAMLGenerator (ObjectWriteContext writeContext , IOContext ioCtxt ,
@@ -265,13 +274,17 @@ protected DumpSettings buildDumperOptions(int jsonFeatures, int yamlFeatures,
265
274
opt .setIndicatorIndent (1 );
266
275
opt .setIndent (2 );
267
276
}
277
+ // 14-May-2018: [dataformats-text#84] allow use of platform linefeed
278
+ if (Feature .USE_PLATFORM_LINE_BREAKS .enabledIn (_formatFeatures )) {
279
+ opt .setLineBreak (DumperOptions .LineBreak .getPlatformLineBreak ());
280
+ }
268
281
return opt ;
269
282
}
270
283
271
284
/*
272
- /**********************************************************
285
+ /**********************************************************************
273
286
/* Versioned
274
- /**********************************************************
287
+ /**********************************************************************
275
288
*/
276
289
277
290
@ Override
@@ -280,9 +293,9 @@ public Version version() {
280
293
}
281
294
282
295
/*
283
- /**********************************************************
296
+ /**********************************************************************
284
297
/* Overridden methods, configuration
285
- /**********************************************************
298
+ /**********************************************************************
286
299
*/
287
300
288
301
/**
@@ -333,9 +346,9 @@ public boolean canUseSchema(FormatSchema schema) {
333
346
//@Override public void setSchema(FormatSchema schema)
334
347
335
348
/*
336
- /**********************************************************
349
+ /**********************************************************************
337
350
/* Extended API, configuration
338
- /**********************************************************
351
+ /**********************************************************************
339
352
*/
340
353
341
354
public YAMLGenerator enable (Feature f ) {
@@ -409,9 +422,9 @@ private final void _writeFieldName(String name)
409
422
}
410
423
411
424
/*
412
- /**********************************************************
425
+ /**********************************************************************
413
426
/* Public API: low-level I/O
414
- /**********************************************************
427
+ /**********************************************************************
415
428
*/
416
429
417
430
@ Override
@@ -432,9 +445,9 @@ public void close() throws IOException
432
445
}
433
446
434
447
/*
435
- /**********************************************************
448
+ /**********************************************************************
436
449
/* Public API: structural output
437
- /**********************************************************
450
+ /**********************************************************************
438
451
*/
439
452
440
453
@ Override
@@ -493,9 +506,9 @@ public final void writeEndObject() throws IOException
493
506
}
494
507
495
508
/*
496
- /**********************************************************
509
+ /**********************************************************************
497
510
/* Output method implementations, textual
498
- /**********************************************************
511
+ /**********************************************************************
499
512
*/
500
513
501
514
@ Override
@@ -555,9 +568,9 @@ public final void writeUTF8String(byte[] text, int offset, int len)
555
568
}
556
569
557
570
/*
558
- /**********************************************************
571
+ /**********************************************************************
559
572
/* Output method implementations, unprocessed ("raw")
560
- /**********************************************************
573
+ /**********************************************************************
561
574
*/
562
575
563
576
@ Override
@@ -596,9 +609,9 @@ public void writeRawValue(char[] text, int offset, int len) throws IOException {
596
609
}
597
610
598
611
/*
599
- /**********************************************************
612
+ /**********************************************************************
600
613
/* Output method implementations, base64-encoded binary
601
- /**********************************************************
614
+ /**********************************************************************
602
615
*/
603
616
604
617
@ Override
@@ -616,9 +629,9 @@ public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int l
616
629
}
617
630
618
631
/*
619
- /**********************************************************
632
+ /**********************************************************************
620
633
/* Output method implementations, scalars
621
- /**********************************************************
634
+ /**********************************************************************
622
635
*/
623
636
624
637
@ Override
@@ -704,9 +717,9 @@ public void writeNull() throws IOException
704
717
}
705
718
706
719
/*
707
- /**********************************************************
720
+ /**********************************************************************
708
721
/* Public API, write methods, Native Ids
709
- /**********************************************************
722
+ /**********************************************************************
710
723
*/
711
724
712
725
@ Override
@@ -749,9 +762,9 @@ public void writeObjectId(Object id)
749
762
}
750
763
751
764
/*
752
- /**********************************************************
765
+ /**********************************************************************
753
766
/* Implementations for methods from base class
754
- /**********************************************************
767
+ /**********************************************************************
755
768
*/
756
769
757
770
@ Override
@@ -770,9 +783,9 @@ protected void _releaseBuffers() {
770
783
}
771
784
772
785
/*
773
- /**********************************************************
786
+ /**********************************************************************
774
787
/* Internal methods
775
- /**********************************************************
788
+ /**********************************************************************
776
789
*/
777
790
778
791
// Implicit means that (type) tags won't be shown, right?
0 commit comments