Skip to content

Commit a05200c

Browse files
committed
Backported #84 implementation to 2.9
1 parent 52e0851 commit a05200c

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ Fabrice Delhoste (spifd@github)
2121
* Reported #74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties
2222
(2.9.5)
2323

24+
Thomas Hauk (thauk-copperleaf@github)
25+
26+
* Contibuted #84 (yaml): Add option to allow use of platform-linefeed
27+
(`YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS`)
28+
(2.9.6)

release-notes/VERSION-2.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Modules:
88
=== Releases ===
99
------------------------------------------------------------------------
1010

11+
2.9.6 (not yet released)
12+
13+
#84 (yaml): Add option to allow use of platform-linefeed
14+
(`YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS`)
15+
(contributed by Thomas H)
16+
1117
2.9.5 (26-Mar-2018)
1218

1319
#74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties

yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ public enum Feature implements FormatFeature // since 2.9
113113
*
114114
* @since 2.9
115115
*/
116-
INDENT_ARRAYS(false)
116+
INDENT_ARRAYS(false),
117+
118+
/**
119+
* Option passed to SnakeYAML that determines if the line breaks used for
120+
* serialization should be same as what the default is for current platform.
121+
* If disabled, Unix linefeed ({@code \n}) will be used.
122+
* <p>
123+
* Default value is `false` for backwards compatibility.
124+
*
125+
* @since 2.9.6
126+
*/
127+
USE_PLATFORM_LINE_BREAKS(false),
117128
;
118129

119130
protected final boolean _defaultState;
@@ -266,6 +277,10 @@ protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures,
266277
opt.setIndicatorIndent(1);
267278
opt.setIndent(2);
268279
}
280+
// 14-May-2018: [dataformats-text#84] allow use of platform linefeed
281+
if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) {
282+
opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak());
283+
}
269284
return opt;
270285
}
271286

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeatureTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
88
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
99
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
10-
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
1110

1211
public class GeneratorFeatureTest extends ModuleTestBase
1312
{

0 commit comments

Comments
 (0)