@Signature(@Arg(value = "flags", optional = @Optional("0"))) public Memory __construct(Environment env, Memory... args) { DumperOptions options = new DumperOptions(); int flags = args[0].toInteger(); options.setPrettyFlow((flags & SERIALIZE_PRETTY_FLOW) == SERIALIZE_PRETTY_FLOW); options.setDefaultFlowStyle((flags & SERIALIZE_PRETTY_FLOW) == SERIALIZE_PRETTY_FLOW ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.AUTO); options.setCanonical((flags & SERIALIZE_CANONICAL) == SERIALIZE_CANONICAL); options.setExplicitStart((flags & SERIALIZE_EXPLICIT_START) == SERIALIZE_EXPLICIT_START); options.setExplicitEnd((flags & SERIALIZE_EXPLICIT_END) == SERIALIZE_EXPLICIT_END); options.setSplitLines(!((flags & SERIALIZE_NOT_SPLIT_LINES) == SERIALIZE_NOT_SPLIT_LINES)); yaml = new Yaml(options); return Memory.NULL; }
protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, org.yaml.snakeyaml.DumperOptions.Version version) { DumperOptions opt = new DumperOptions(); // would we want canonical? if (Feature.CANONICAL_OUTPUT.enabledIn(_formatFeatures)) { opt.setCanonical(true); } else { opt.setCanonical(false); // if not, MUST specify flow styles opt.setDefaultFlowStyle(FlowStyle.BLOCK); } // split-lines for text blocks? opt.setSplitLines(Feature.SPLIT_LINES.enabledIn(_formatFeatures)); // array indentation? if (Feature.INDENT_ARRAYS.enabledIn(_formatFeatures)) { // But, wrt [dataformats-text#34]: need to set both to diff values to work around bug // (otherwise indentation level is "invisible". Note that this should NOT be necessary // but is needed up to at least SnakeYAML 1.18. // Also looks like all kinds of values do work, except for both being 2... weird. opt.setIndicatorIndent(1); opt.setIndent(2); } // 14-May-2018: [dataformats-text#84] allow use of platform linefeed if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) { opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); } return opt; }
protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, org.yaml.snakeyaml.DumperOptions.Version version) { DumperOptions opt = new DumperOptions(); // would we want canonical? if (Feature.CANONICAL_OUTPUT.enabledIn(_formatFeatures)) { opt.setCanonical(true); } else { opt.setCanonical(false); // if not, MUST specify flow styles opt.setDefaultFlowStyle(FlowStyle.BLOCK); } // split-lines for text blocks? opt.setSplitLines(Feature.SPLIT_LINES.enabledIn(_formatFeatures)); // array indentation? if (Feature.INDENT_ARRAYS.enabledIn(_formatFeatures)) { // But, wrt [dataformats-text#34]: need to set both to diff values to work around bug // (otherwise indentation level is "invisible". Note that this should NOT be necessary // but is needed up to at least SnakeYAML 1.18. // Also looks like all kinds of values do work, except for both being 2... weird. opt.setIndicatorIndent(1); opt.setIndent(2); } // 14-May-2018: [dataformats-text#84] allow use of platform linefeed if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) { opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); } return opt; }
public String convertToPipelineTemplate(Map<String, Object> pipeline) { Map<String, Object> p = new LinkedHashMap<>(); p.put("schema", "1"); p.put("id", String.format("%s-%s", pipeline.getOrDefault("application", "spinnaker"), ((String) pipeline.getOrDefault("name", "generatedTemplate")).replaceAll("\\W", ""))); p.put("metadata", generateMetadata(pipeline)); p.put("protect", false); p.put("configuration", generateConfiguration(pipeline)); p.put("variables", new ArrayList<>()); p.put("stages", convertStages((List) pipeline.get("stages"))); Representer representer = new Representer(); DumperOptions options = new DumperOptions(); options.setIndent(2); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setSplitLines(false); Yaml yaml = new Yaml(new SafeConstructor(), representer, options); String output = yaml.dump(p); return String.format("%s%s", loadTemplateHeader(), output); }
private static Yaml createYaml() { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(true); dumperOptions.setSplitLines(false); return new Yaml(new ValueTypeRepresenter(), dumperOptions); }
private static Yaml createYaml() { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(true); dumperOptions.setSplitLines(false); return new Yaml(new ValueTypeRepresenter(), dumperOptions); }
protected DumperOptions getDumperOptions() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setPrettyFlow(true); options.setIndent(2); options.setSplitLines(false); return options; } }
DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setSplitLines(false);
dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(false); dumperOptions.setSplitLines(false); Yaml yaml = new Yaml(dumperOptions); configValues.setRaw(yaml.dump(configValueMap));
protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, org.yaml.snakeyaml.DumperOptions.Version version) { DumperOptions opt = new DumperOptions(); // would we want canonical? if (Feature.CANONICAL_OUTPUT.enabledIn(_formatFeatures)) { opt.setCanonical(true); } else { opt.setCanonical(false); // if not, MUST specify flow styles opt.setDefaultFlowStyle(FlowStyle.BLOCK); } // [dataformat#35]: split-lines for text blocks? opt.setSplitLines(Feature.SPLIT_LINES.enabledIn(_formatFeatures)); return opt; }
dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(false); dumperOptions.setSplitLines(false); Yaml yaml = new Yaml(dumperOptions); configValues.setRaw(yaml.dump(configValueMap));
protected DumperOptions buildDumperOptions(int streamWriteFeatures, int yamlFeatures, org.yaml.snakeyaml.DumperOptions.Version version) { DumperOptions opt = new DumperOptions(); // would we want canonical? if (Feature.CANONICAL_OUTPUT.enabledIn(_formatWriteFeatures)) { opt.setCanonical(true); } else { opt.setCanonical(false); // if not, MUST specify flow styles opt.setDefaultFlowStyle(FlowStyle.BLOCK); } // split-lines for text blocks? opt.setSplitLines(Feature.SPLIT_LINES.enabledIn(_formatWriteFeatures)); // array indentation? if (Feature.INDENT_ARRAYS.enabledIn(_formatWriteFeatures)) { // But, wrt [dataformats-text#34]: need to set both to diff values to work around bug // (otherwise indentation level is "invisible". Note that this should NOT be necessary // but is needed up to at least SnakeYAML 1.18. // Also looks like all kinds of values do work, except for both being 2... weird. opt.setIndicatorIndent(1); opt.setIndent(2); } // 14-May-2018: [dataformats-text#84] allow use of platform linefeed if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatWriteFeatures)) { opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); } return opt; }