From 27232b3056d7f2a40da9f7cbf29a02579633f7e9 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Fri, 19 Oct 2018 11:33:16 -0500 Subject: Properly map Psych flow styles to SnakeYAML flow styles. --- ext/java/PsychEmitter.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ext/java/PsychEmitter.java b/ext/java/PsychEmitter.java index b45b78e..1372c2f 100644 --- a/ext/java/PsychEmitter.java +++ b/ext/java/PsychEmitter.java @@ -222,7 +222,7 @@ public class PsychEmitter extends RubyObject { implicit.isTrue(), NULL_MARK, NULL_MARK, - SEQUENCE_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW); + FLOW_STYLES[style.convertToInteger().getIntValue()]); emit(context, event); return this; } @@ -249,7 +249,7 @@ public class PsychEmitter extends RubyObject { implicit.isTrue(), NULL_MARK, NULL_MARK, - MAPPING_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW); + FLOW_STYLES[style.convertToInteger().getIntValue()]); emit(context, event); return this; } @@ -336,7 +336,7 @@ public class PsychEmitter extends RubyObject { // Map style constants from Psych values (ANY = 0 ... FOLDED = 5) // to SnakeYaml values; see psych/nodes/scalar.rb. - private static final DumperOptions.ScalarStyle[] SCALAR_STYLES = new DumperOptions.ScalarStyle[] { + private static final DumperOptions.ScalarStyle[] SCALAR_STYLES = { DumperOptions.ScalarStyle.PLAIN, // ANY DumperOptions.ScalarStyle.PLAIN, DumperOptions.ScalarStyle.SINGLE_QUOTED, @@ -344,4 +344,10 @@ public class PsychEmitter extends RubyObject { DumperOptions.ScalarStyle.LITERAL, DumperOptions.ScalarStyle.FOLDED }; + + private static final DumperOptions.FlowStyle[] FLOW_STYLES = { + DumperOptions.FlowStyle.AUTO, + DumperOptions.FlowStyle.BLOCK, + DumperOptions.FlowStyle.FLOW + }; } -- cgit v1.2.3