示例#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
 public Object load(YamlDecoder dec) {
   dec.setConfig(this);
   Object ret = null;
   try {
     ret = dec.readObject();
   } catch (EOFException e) {
   }
   return ret;
 }
示例#4
0
 public <T> YamlStream<T> loadStreamOfType(YamlDecoder dec, Class<T> clazz) {
   dec.setConfig(this);
   return dec.asStreamOfType(clazz);
 }
示例#5
0
 public YamlStream loadStream(YamlDecoder dec) {
   dec.setConfig(this);
   return dec.asStream();
 }
示例#6
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;
 }