summaryrefslogtreecommitdiff
path: root/ext/java
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2018-10-19 11:33:16 -0500
committerCharles Oliver Nutter <headius@headius.com>2018-10-19 11:33:16 -0500
commit27232b3056d7f2a40da9f7cbf29a02579633f7e9 (patch)
tree9382965c0dee6d98db34377cbaaf33e2b349cfd0 /ext/java
parent94d35a10223376eb1eecb77a52bdc9f4498ed774 (diff)
downloadpsych-27232b3056d7f2a40da9f7cbf29a02579633f7e9.tar.gz
Properly map Psych flow styles to SnakeYAML flow styles.
Diffstat (limited to 'ext/java')
-rw-r--r--ext/java/PsychEmitter.java12
1 files 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
+ };
}