예제 #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;
 }