Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml.load()


    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;
    }


    // Based on com.yammer.dropwizard.validation.Validator
View Full Code Here


            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

        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

        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

            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

            org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor(Config.class);
            TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class);
            seedDesc.putMapPropertyType("parameters", String.class, String.class);
            constructor.addTypeDescription(seedDesc);
            Yaml yaml = new Yaml(new Loader(constructor));
            conf = (Config)yaml.load(input);

            logger.info("Data files directories: " + Arrays.toString(conf.data_file_directories));
            logger.info("Commit log directory: " + conf.commitlog_directory);

            if (conf.commitlog_sync == null)
View Full Code Here

        {
            final Constructor constructor = new Constructor(NodeToolHelp.class);
            TypeDescription desc = new TypeDescription(NodeToolHelp.class);
            desc.putListPropertyType("commands", NodeToolHelp.NodeToolCommand.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (NodeToolHelp)yaml.load(is);
        }
        finally
        {
            FileUtils.closeQuietly(is);
        }
View Full Code Here

                throw new RuntimeException("Found multiple " + name + " resources. You're probably bundling the Storm jars with your topology jar. "
                  + resources);
            }
            URL resource = resources.iterator().next();
            Yaml yaml = new Yaml();
            Map ret = (Map) yaml.load(new InputStreamReader(resource.openStream()));
            if(ret==null) ret = new HashMap();
           

            return new HashMap(ret);
           
View Full Code Here

  }

  private void initialize(InputStream regexYaml) {
    Yaml yaml = new Yaml(new SafeConstructor());
    @SuppressWarnings("unchecked")
    Map<String,List<Map<String,String>>> regexConfig = (Map<String,List<Map<String,String>>>) yaml.load(regexYaml);

    List<Map<String,String>> uaParserConfigs = regexConfig.get("user_agent_parsers");
    if (uaParserConfigs == null) {
      throw new IllegalArgumentException("user_agent_parsers is missing from yaml");
    }
View Full Code Here

            URL resource = resources.iterator().next();
            Yaml yaml = new Yaml(new SafeConstructor());
            Map ret = null;
            InputStream input = resource.openStream();
            try {
                ret = (Map) yaml.load(new InputStreamReader(input));
            } finally {
                input.close();
            }
            if(ret==null) ret = new HashMap();
           
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.