public void writeSidebar(Map<String, Object> sidebar) throws IOException { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(FlowStyle.BLOCK); if (SystemUtils.IS_OS_WINDOWS) { options.setLineBreak(LineBreak.WIN); } Yaml yaml = new Yaml(options); writer.write(sidebarPath, Arrays.asList(yaml.dump(sidebar))); System.out.println("Generated " + sidebarPath); } }
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; }
@Override public void setLineBreak(LineBreak lineBreak) { super.setLineBreak(LineBreak.getPlatformLineBreak()); } }
private String convertToYml(Map<String, Object> dockerComposeData) { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setLineBreak(LineBreak.WIN); Representer representer = new SkipNullRepresenter(); representer.addClassTag(LBConfigMetadataStyle.class, Tag.MAP); Yaml yaml = new Yaml(representer, options); String yamlStr = yaml.dump(dockerComposeData); return yamlStr.replaceAll("[$]", "\\$\\$"); }
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setPrettyFlow(true); dumperOptions.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); Yaml yaml = new Yaml(dumperOptions); return yaml.dump(skipperConfigValuesMap);
private DumperOptions dumperOptions() { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setIndent(4); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); dumperOptions.setLineBreak(DumperOptions.LineBreak.UNIX); dumperOptions.setPrettyFlow(true); return dumperOptions; } }
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setPrettyFlow(true); dumperOptions.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); Yaml yaml = new Yaml(dumperOptions); return yaml.dump(skipperConfigValuesMap);
protected Yaml buildYaml() { Constructor constructor = new Constructor(); Representer representer = new Representer(); representer.setDefaultFlowStyle(FlowStyle.BLOCK); representer.setDefaultScalarStyle(ScalarStyle.PLAIN); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setAllowReadOnlyProperties(true); dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK); dumperOptions.setDefaultScalarStyle(ScalarStyle.PLAIN); dumperOptions.setLineBreak(this.getLineBreak()); LimitedResolver limitedResolver = new LimitedResolver(); return new Yaml(constructor, representer, dumperOptions, limitedResolver); }
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; }