Пример #1
0
 /**
  * Loads a YamlConfig from a resource on the classpath
  *
  * @param filename the name of the resource
  * @return a YamlConfig object
  * @throws EOFException
  */
 public static YamlConfig fromResource(String filename) throws EOFException {
   YamlDecoder dec =
       new YamlDecoder(
           YamlConfig.class.getClassLoader().getResourceAsStream(filename), new YamlConfig());
   YamlConfig ret = dec.readObjectOfType(YamlConfig.class);
   dec.close();
   return ret;
 }
Пример #2
0
 public <T> T loadType(YamlDecoder dec, Class<T> clazz) {
   dec.setConfig(this);
   T ret = null;
   try {
     ret = dec.readObjectOfType(clazz);
   } catch (EOFException e) {
   }
   return ret;
 }
Пример #3
0
 /**
  * Loads a YamlConfig from a Yaml configuration file
  *
  * @param filename the name of the file to load
  * @return a YamlConfig object
  * @throws FileNotFoundException
  * @throws EOFException
  */
 public static YamlConfig fromFile(String filename) throws FileNotFoundException, EOFException {
   YamlDecoder dec = new YamlDecoder(new FileInputStream(filename), new YamlConfig());
   YamlConfig ret = dec.readObjectOfType(YamlConfig.class);
   dec.close();
   return ret;
 }