Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml


        super(url);
    }

    @Override
    public void load(Reader in) throws ConfigurationException {
        Yaml yaml = new Yaml();
        org.yaml.snakeyaml.nodes.Node node = yaml.compose(in);
        Node root = new Node();
        build(node, root);
        setRootNode(root);
    }
View Full Code Here


      {
        File f=new File(higopath,name);
        if(f.exists())
        {
             InputStreamReader isr = new InputStreamReader (new FileInputStream (f));
             Yaml yaml = new Yaml();
            Map ret = (Map) yaml.load(isr);
            if (ret != null)
            {
              return new HashMap(ret);
            }
        }
      }
     
     
      Enumeration resources = Thread.currentThread()
          .getContextClassLoader().getResources(name);
      if (!resources.hasMoreElements()) {
        if (mustExist)
          throw new RuntimeException(
              "Could not find config file on classpath " + name);
        else
          return new HashMap();
      }
      URL resource = (URL) resources.nextElement();
      Yaml yaml = new Yaml();
      Map ret = (Map) yaml.load(new InputStreamReader(resource
          .openStream()));
      if (ret == null)
      {
        ret = new HashMap();
      }
View Full Code Here

            if(resources.size() > 1) {
                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(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

        // use "|" instead of "," for field delimiter
        RecordFormat format = new DelimitedRecordFormat()
                .withFieldDelimiter("|");

        Yaml yaml = new Yaml();
        InputStream in = new FileInputStream(args[1]);
        Map<String, Object> yamlConf = (Map<String, Object>) yaml.load(in);
        in.close();
        config.put("hdfs.config", yamlConf);

        HdfsBolt bolt = new HdfsBolt()
                .withConfigKey("hdfs.config")
View Full Code Here

        /* Use Tag.MAP to avoid the class name being included as global tag */
        representer.addClassTag(RawColumnFamily.class, Tag.MAP);
        representer.addClassTag(Keyspaces.class, Tag.MAP);
        representer.addClassTag(ColumnDefinition.class, Tag.MAP);
        Dumper dumper = new Dumper(representer, options);
        Yaml yaml = new Yaml(dumper);
        Keyspaces ks = new Keyspaces();
        ks.keyspaces = keyspaces;
        return yaml.dump(ks);
    }
View Full Code Here

        SkipNullRepresenter representer = new SkipNullRepresenter();
        /* Use Tag.MAP to avoid the class name being included as global tag */
        representer.addClassTag(Config.class, Tag.MAP);
        representer.addClassTag(RawColumnFamily.class, Tag.MAP);
        Dumper dumper = new Dumper(representer, options);
        Yaml yaml = new Yaml(dumper);
        String output = yaml.dump(conf);
       
        /* Write to output file */
        BufferedWriter out = new BufferedWriter(new FileWriter(outfile));
        out.write("# Cassandra YAML generated from previous config\n");
        out.write("# Configuration wiki: http://wiki.apache.org/cassandra/StorageConfiguration\n");
View Full Code Here

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

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

      imageDesc.putListPropertyType("images", String.class);
      constructor.addTypeDescription(imageDesc);

      // Issue 855: testng is rev-locking us to snakeyaml 1.6
      // we have to use old constructor until this is fixed
      Yaml yaml = new Yaml(new Loader(constructor));
      Config config = (Config) yaml.load(yamlDescriptor);
      checkState(config != null, "missing config: class");
      checkState(config.images != null, "missing images: collection");

      Map<Image, YamlImage> backingMap = Maps.newLinkedHashMap();
      for (YamlImage yamlImage : config.images) {
View Full Code Here

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

TOP

Related Classes of org.yaml.snakeyaml.Yaml

Copyright © 2018 www.massapicom. 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.