Refine search
public void writeToYmlSettingsFile(File file) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setPrettyFlow(true); dumperOptions.setDefaultFlowStyle(BLOCK); Yaml yaml = new Yaml(dumperOptions); String output = ELASTICSEARCH_YML_OPTIONS_HEADER + yaml.dump(elasticsearchSettings); try { Files.write(file.toPath(), output.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new IllegalStateException("Cannot write Elasticsearch yml settings file", e); } } }
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)); }
private static DumperOptions initDumperOptions(Representer representer) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); dumperOptions.setTimeZone(representer.getTimeZone()); return dumperOptions; }
public void save(Writer output) { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); getYaml().dump(this, output); }
@SuppressWarnings("unchecked") private static Map<String, String> parseYamlStream(InputStream tenantStream) { Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(), new Resolver() { @Override protected void addImplicitResolvers() { } // forces all yaml values to be parsed as Strings } ); return (Map<String, String>) yaml.load(tenantStream); } }
private static Yaml getYamlParser() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); return new Yaml(new SafeConstructor(), new Representer(), options); }
configValueMap.put("spec", specMap); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(false); dumperOptions.setSplitLines(false); Yaml yaml = new Yaml(dumperOptions); configValues.setRaw(yaml.dump(configValueMap));
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) { super(new LinkedHashMap<>(), writeDefaults); this.format = format; DumperOptions options = new DumperOptions(); options.setIndent(4); options.setDefaultFlowStyle(format.getStyle()); Representer representer = new FancyRepresenter(); representer.setDefaultFlowStyle(format.getStyle()); yaml = new Yaml(new SafeConstructor(), representer, options); this.file = file; }
private Yaml newYaml() { return new Yaml(new SafeConstructor(), new Representer(), new DumperOptions(), new YamlTagResolver()); } }
private static Yaml getYaml() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); StringExRepresent representer = new StringExRepresent(); PropertyUtils propertyUtils = representer.getPropertyUtils(); propertyUtils.setSkipMissingProperties(true); return new Yaml(new StringExConstructor(), representer, options); }
private static Yaml getYaml() { Representer representer = new TapeRepresenter(); representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG); Constructor constructor = new TapeConstructor(); constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG)); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(BLOCK); dumperOptions.setWidth(256); Yaml yaml = new Yaml(constructor, representer, dumperOptions); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; } }
@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 Yaml createYaml() { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED); dumperOptions.setPrettyFlow(true); dumperOptions.setSplitLines(false); return new Yaml(new ValueTypeRepresenter(), dumperOptions); }
@Override protected Yaml initialValue() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setPrettyFlow(false); options.setIndent(2); return new Yaml(new YamlConstructor(), new Representer(), options); } };
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); }
private static void configYamlFormat(final ToolBelt belt, final RdClientConfig config) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle( "BLOCK".equalsIgnoreCase(config.getString("RD_YAML_FLOW", "BLOCK")) ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW ); dumperOptions.setPrettyFlow(config.getBool("RD_YAML_PRETTY", true)); Representer representer = new Representer(); representer.addClassTag(JobItem.class, Tag.MAP); representer.addClassTag(ScheduledJobItem.class, Tag.MAP); representer.addClassTag(DateInfo.class, Tag.MAP); representer.addClassTag(Execution.class, Tag.MAP); belt.formatter(new YamlFormatter(DataOutputAsFormatable, new Yaml(representer, dumperOptions))); belt.channels().infoEnabled(false); belt.channels().warningEnabled(false); belt.channels().errorEnabled(false); }
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; }
public YamlReader(Constructor rootConstructor) { Representer representer = new Representer(); representer.getPropertyUtils().setSkipMissingProperties(true); yamlParser = new Yaml(rootConstructor, representer, new DumperOptions(), new CustomResolver()); }
/** * Yaml representation. * * @return Yaml representation */ @Override public String toString() { StringWriter w = new StringWriter(); DumperOptions dumperOpts = new DumperOptions(); dumperOpts.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOpts.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); YamlUtil.getSafeYaml(dumperOpts).dump(raw, w); return w.toString(); } }
protected DumperOptions getDumperOptions() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW); options.setPrettyFlow(true); options.setIndent(2); return options; }