public static <K extends Comparable<? super K>, V extends Object> String prettyPrintYaml(Map<K,V> map) { DumperOptions dump = new DumperOptions(); dump.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dump.setPrettyFlow(true); dump.setIndent(2); dump.setCanonical(false); dump.setExplicitStart(true); Yaml yaml = new Yaml(dump); return yaml.dump(sortByKeys(map)); }
@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; }
private static DumperOptions getDumperOptions() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setIndent(4); options.setAllowReadOnlyProperties(true); options.setExplicitStart(true); return options; }
/** * Returns a new, properly configured YAML instance, able to write and read * key mappings. * * @return a new {@link Yaml} instance. */ private static final Yaml getYaml() { final Representer representer = new Representer(); representer.addClassTag( InputTriggerDescription.class, tag ); final Constructor constructor = new Constructor(); constructor.addTypeDescription( new TypeDescription( InputTriggerDescription.class, tag ) ); final DumperOptions options = new DumperOptions(); options.setExplicitStart( true ); final Yaml yaml = new Yaml( constructor, representer, options ); return yaml; }
protected Yaml getYaml() { if (this._yaml == null) { final Constructor constructor = new MappingConstructor(); final Loader loader = new Loader(constructor); final DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setExplicitStart(true); dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); final MappingRepresenter representer = new MappingRepresenter(); final Dumper dumper = new Dumper(representer, dumperOptions); this._yaml = new Yaml(loader, dumper); } return this._yaml; }
private YamlFormatter(Builder builder) { options = new DumperOptions(); options.setExplicitStart(builder.explicitStart); options.setExplicitEnd(builder.explicitEnd); options.setIndent(builder.indent); options.setWidth(builder.lineLength); options.setDefaultFlowStyle(builder.flowStyle); options.setPrettyFlow(builder.prettyFlow); options.setDefaultScalarStyle(builder.scalarStyle); }
options.setExplicitStart(true); options.setCanonical(false); options.setPrettyFlow(true);