Examples of Yaml


Examples of org.yaml.snakeyaml.Yaml

    @SuppressWarnings("unchecked")
    public boolean load(InputStream inputFile, String type, boolean overwrite)
    {
        if (type.equalsIgnoreCase("yaml"))
        {
            final Yaml yamlParser = new Yaml();
            final Map<String, Object> data = (Map<String, Object>) yamlParser
                    .load(inputFile);
            if (data != null)
            {
                merge(data, config, overwrite);
            }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

    }
   
    public void save(File file) throws Exception
    {
        final OutputStream out = new FileOutputStream(file);
        final Yaml yaml = new Yaml();
        final byte[] data = yaml.dump(config).getBytes("UTF-8");
        out.write(data);
        out.close();
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

      return longUrl;
    }
  }

  public static String gistText(String text) {
    Yaml yaml = YAML_INSTANCE.get();
    OutputStreamWriter requestWriter = null;
    InputStream responseReader = null;
    try {
      URLConnection conn = GIST_POST_URL.openConnection();
      conn.setDoOutput(true);
      conn.setDoInput(true);

      Map<String, Object> request = new HashMap<>();    // {
      request.put("description", "PEX Error Report");     //   "description": "PEX Error Report",
      request.put("public", "false");             //   "public": false,
      Map<String, Object> filesMap = new HashMap<>();     //   "files": {
      Map<String, Object> singleFileMap = new HashMap<>()//     "report.md": {
      singleFileMap.put("content", text);           //       "content": <text>
      filesMap.put("report.md", singleFileMap);       //     }
      request.put("files", filesMap);             //   }
                                  // }
      yaml.dump(request, (requestWriter = new OutputStreamWriter(conn.getOutputStream())));

      Map<?, ?> data = (Map<?, ?>) yaml.load((responseReader = conn.getInputStream()));
      if (data.containsKey("html_url")) {
        return data.get("html_url").toString();
      }
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

        assert is != null;

        try
        {
            final Constructor constructor = new Constructor(NodeToolHelp.class);
            final Yaml yaml = new Yaml(constructor);
            return (NodeToolHelp)yaml.load(is);
        }
        finally
        {
            FileUtils.closeQuietly(is);
        }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

        try {
            yaml = engine.createTemplate(config).make(new MissingPropForwardingMap(envVars)).toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return (Map) new Yaml().load(yaml);
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

    }


    public static ReporterConfig loadFromFile(String fileName) throws IOException
    {
        Yaml yaml = new Yaml(new Constructor(ReporterConfig.class));
        InputStream input = new FileInputStream(new File(fileName));
        ReporterConfig config = (ReporterConfig) yaml.load(input);
        return config;
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

            }
            Constructor constructor = new Constructor(CassandraConfig.class);
            TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class);
            seedDesc.putMapPropertyType("parameters", String.class, String.class);
            constructor.addTypeDescription(seedDesc);
            Yaml yaml = new Yaml(constructor);
            config = (CassandraConfig) yaml.load(input);
        } catch (YAMLException e) {
            throw new ConfigurationException("Invalid yaml", e);
        } finally {
            FileUtils.closeQuietly(input);
        }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

        stackDescription.putListPropertyType("availableArchetypeVersions", ArchetypeVersionImpl.class);
        stackDescription.putListPropertyType("minorReleases", MinorReleaseImpl.class);
        stackDescription.putListPropertyType("majorReleases", MajorReleaseImpl.class);
  
        constructor.addTypeDescription(stackDescription);
        Yaml yaml = new Yaml(constructor);
        Stacks data = (Stacks) yaml.load(is);
        return data;
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

    public static class YamlSettingsLoader {

        public static Map<String, String> load(String source) throws IOException {
            // replace tabs with whitespace (yaml does not accept tabs, but many users might use it still...)
            source = source.replace("\t", "  ");
            Yaml yaml = new Yaml();
            Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(source);
            StringBuilder sb = new StringBuilder();
            Map<String, String> settings = newHashMap();
            if (yamlMap == null) {
                return settings;
            }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml

            serializeMap(settings, sb, path, yamlMap);
            return settings;
        }

        public static Map<String, String> load(byte[] source) throws IOException {
            Yaml yaml = new Yaml();
            Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(source.toString());
            StringBuilder sb = new StringBuilder();
            Map<String, String> settings = newHashMap();
            if (yamlMap == null) {
                return settings;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.