Package org.yaml.snakeyaml

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


      throw new IllegalArgumentException(String.format("File %s was not found on classpath", path));
    }

    Yaml yaml = new Yaml();
    while (resources.hasMoreElements()) {
      appendData(yaml.loadAs(resources.nextElement().openStream(), Data.class));
    }
  }

  private void appendData(Data dataMaster) {
    dataSource.putAll(dataMaster.getData());
View Full Code Here


            seedDesc.putMapPropertyType("parameters", String.class, String.class);
            constructor.addTypeDescription(seedDesc);
            MissingPropertiesChecker propertiesChecker = new MissingPropertiesChecker();
            constructor.setPropertyUtils(propertiesChecker);
            Yaml yaml = new Yaml(constructor);
            Config result = yaml.loadAs(input, Config.class);
            result.configHintedHandoff();
            propertiesChecker.check();
            return result;
        }
        catch (YAMLException e)
View Full Code Here

   * @param inputStream the input stream
   */
  @SuppressWarnings("unchecked")
  public final void load(final InputStream inputStream) {
    final Yaml yaml = new Yaml();
    config = yaml.loadAs(inputStream, Map.class);
  }
 
  /**
   * Get the full configuration
   * returns null if no configuration file is loaded.
View Full Code Here

        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("calendar: 2001-09-08T17:46:40-8:00\nname: lunch\n", output);
        //
        Yaml loader = new Yaml();
        CalendarBean parsed = loader.loadAs(output, CalendarBean.class);
        assertEquals(bean.getCalendar(), parsed.getCalendar());
    }

    /**
     * Daylight Saving Time is in effect on this date/time in
View Full Code Here

        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals(warning, "calendar: " + etalon + "\nname: lunch\n", output);
        //
        Yaml loader = new Yaml();
        CalendarBean parsed = loader.loadAs(output, CalendarBean.class);
        assertFalse("TimeZone must deviate.", bean.getCalendar().equals(parsed.getCalendar()));
        assertEquals(bean.getCalendar().getTimeInMillis(), parsed.getCalendar().getTimeInMillis());
    }

    public void testLoadBean() {
View Full Code Here

        assertEquals(bean.getCalendar().getTimeInMillis(), parsed.getCalendar().getTimeInMillis());
    }

    public void testLoadBean() {
        Yaml beanLoader = new Yaml();
        CalendarBean bean = beanLoader.loadAs(
                "calendar:  2001-12-14t21:59:43.10-05:00\nname: dinner", CalendarBean.class);
        assertEquals("dinner", bean.getName());
        Calendar calendar = bean.getCalendar();
        assertEquals(TimeZone.getTimeZone("GMT-5:00").getOffset(calendar.getTime().getTime()),
                calendar.getTimeZone().getOffset(calendar.getTime().getTime()));
View Full Code Here

   * @throws FileNotFoundException
   */
  @SuppressWarnings("unchecked")
  public void load(InputStream inputStream) {
    Yaml yaml = new Yaml();
    config = yaml.loadAs(inputStream, Map.class);
  }
 
  /**
   * Get the full configuration
   * returns null if no configuration file is loaded
View Full Code Here

   * @throws FileNotFoundException
   */
  @SuppressWarnings("unchecked")
  public final void load(InputStream inputStream) {
    Yaml yaml = new Yaml();
    config = yaml.loadAs(inputStream, Map.class);
  }
 
  /**
   * Get the full configuration
   * returns null if no configuration file is loaded
View Full Code Here

    final Config config;
    if (Files.exists(configFile)) {
      try (InputStream is = Files.newInputStream(configFile)) {
        Yaml yaml = new Yaml();
        config = yaml.loadAs(is, Config.class);
      }
    } else {
      config = new Config();
    }
View Full Code Here

    Config config;
    if (Files.exists(configFile)) {
      try (InputStream is = Files.newInputStream(configFile)) {
        Yaml yaml = new Yaml();
        config = yaml.loadAs(is, Config.class);
      }
    }
    else {
      config = new Config();
    }
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.