/** * Convert this into a YAML String. * @return this as a YAML String. */ public String toYamlString() { Yaml yaml = new Yaml(new SafeConstructor()); StringWriter writer = new StringWriter(); yaml.dump(toConf(), writer); return writer.toString(); }
/** * Parse the TopologyLoadConf from a file in YAML format. * @param file the file to read from * @return the parsed conf * @throws IOException if there is an issue reading the file. */ public static TopologyLoadConf fromConf(File file) throws IOException { Yaml yaml = new Yaml(new SafeConstructor()); Map<String, Object> yamlConf = (Map<String, Object>)yaml.load(new FileReader(file)); return TopologyLoadConf.fromConf(yamlConf); }
/** * Write this out to a file in YAML format. * @param file the file to write to. * @throws IOException if there is an error writing to the file. */ public void writeTo(File file) throws IOException { Yaml yaml = new Yaml(new SafeConstructor()); try (FileWriter writer = new FileWriter(file)) { yaml.dump(toConf(), writer); } }
in = getConfigFileInputStream(name, canMultiple); if (null != in) { Yaml yaml = new Yaml(new SafeConstructor()); Map ret = (Map) yaml.load(new InputStreamReader(in)); if (null != ret) {
Yaml yaml = new Yaml(new SafeConstructor()); Map ret = null; try {
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()); } }
public static Yaml getSafeYaml(Representer representer, DumperOptions dumperOptions) { return new Yaml(new SafeConstructor(), representer, dumperOptions); } }
public PlainYamlObject(final InputStream io) throws IOException { try { yamlObject = new Yaml(new SafeConstructor()).load(io); } finally { io.close(); } }
static public Map<String, Object> parseManifest(String input) { Yaml yaml = new Yaml(new SafeConstructor()); return mapper.convertValue(yaml.load(input), new TypeReference<Map<String, Object>>() {}); }
public static <T> T readYamlValue(String contents, Class<T> expectedType) { org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor()); return Json.mapper().convertValue(yaml.load(contents), expectedType); } }
public static JsonNode readYamlTree(String contents) { org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor()); return Json.mapper().convertValue(yaml.load(contents), JsonNode.class); }
try (InputStream input = new FileInputStream(file)) { Yaml yaml = new Yaml(new SafeConstructor()); yaml.loadAll(input).forEach( System.out::println ); } catch (Throwable e) { System.out.println("ERROR: " + e.getMessage()); }
private static Yaml newYaml() { return new Yaml( BrooklynSystemProperties.YAML_TYPE_INSTANTIATION.isEnabled() ? new Constructor() // allows instantiation of arbitrary Java types : new SafeConstructor() // allows instantiation of limited set of types only ); }
@Bean Yaml yamlParser() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); return new Yaml(new SafeConstructor(), new Representer(), options); }
@Bean Yaml yamlParser() { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); return new Yaml(new SafeConstructor(), new Representer(), options); }
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); }
private static Yaml getYamlParser() { if (yamlParser == null) { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); yamlParser = new Yaml(new SafeConstructor(), new Representer(), options); } return yamlParser; }
public ObjectNode loadString(String content) throws IOException { // here doesn't use jackson-dataformat-yaml so that snakeyaml calls Resolver // and Composer. See also YamlTagResolver. Yaml yaml = new Yaml(new SafeConstructor(), new Representer(), new DumperOptions(), new YamlTagResolver()); ObjectNode object = normalizeValidateObjectNode(yaml.load(content)); return object; }
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) { super(new LinkedHashMap<String, Object>(), writeDefaults); this.format = format; DumperOptions options = new FancyDumperOptions(); 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; }