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