Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml


    if (file == null) {
      throw new FileNotFoundException("null obviously could not be found");
    }
    final Representer r = new Representer();
    r.getPropertyUtils().setSkipMissingProperties(true);
    final Yaml yaml = new Yaml(new CustomClassLoaderConstructor(JProvisionerProfile.class), r);
    final InputStream fis = new FileInputStream(file);
    JProvisionerProfile p = null;
    try {
      p = (JProvisionerProfile) yaml.load(fis);
    } finally {
      try {
        fis.close();
      } catch (Exception e) { }
    }
View Full Code Here


  public static Privileged fromFile(final String filename) throws FileNotFoundException {
    if (filename == null) {
      throw new FileNotFoundException("null obviously could not be found");
    }
    final File file = new File(filename);
    final Yaml yaml = new Yaml(new CustomClassLoaderConstructor(Privileged.class));
    final InputStream fis = new FileInputStream(file);
    Privileged p = null;
    try {
      p = (Privileged) yaml.load(fis);
    } finally {
      try {
        fis.close();
      } catch (Exception e) { }
    }
View Full Code Here

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

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

            if (conf.commitlog_sync == null)
            {
                throw new ConfigurationException("Missing required directive CommitLogSync");
            }
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

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

            if (!System.getProperty("os.arch").contains("64"))
                logger.info("32bit JVM detected.  It is recommended to run Cassandra on a 64bit JVM for better performance.");

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

   * @param input InputStream representing the file
   * @return ClusterConfig Java wrapper of the configuration file
   */
  public YAMLClusterConfig setupCluster(InputStream input) {
    // parse the YAML
    Yaml yaml = new Yaml();
    YAMLClusterConfig cfg = yaml.loadAs(input, YAMLClusterConfig.class);

    // create the cluster
    HelixAdmin helixAdmin = new ZKHelixAdmin(_zkAddress);
    if (cfg.clusterName == null) {
      throw new HelixException("Cluster name is required!");
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

    @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

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.