/** * Parse all YAML documents in a stream and produce corresponding Java * objects. The documents are parsed only when the iterator is invoked. * * @param yaml * YAML data to load from (BOM is respected to detect encoding and removed from the data) * @return an Iterable over the parsed Java objects in this stream in proper * sequence */ public Iterable<Object> loadAll(InputStream yaml) { return loadAll(new UnicodeReader(yaml)); }
public int read(char[] cbuf, int off, int len) throws IOException { init(); return internalIn2.read(cbuf, off, len); } }
import org.yaml.snakeyaml.reader.UnicodeReader; //more code private String readStream(InputStream inputStream) throws IOException { UnicodeReader unicodeReader = new UnicodeReader(inputStream); char[] charBuffer = new char[BUFFER_SIZE]; int read; StringBuilder buffer = new StringBuilder(BUFFER_SIZE); while ((read = unicodeReader.read(charBuffer,0,BUFFER_SIZE)) != -1) { buffer.append(charBuffer, 0, read); } return buffer.toString(); }
public Charset getEncoding() { return Charset.forName(((UnicodeReader) this.stream).getEncoding()); }
private static String readYamlFileToString(File yamlFile) throws IOException { // using UnicodeReader to read the correct encoding according to BOM try (UnicodeReader reader = new UnicodeReader(new FileInputStream(yamlFile))) { StringBuffer sb = new StringBuffer(); char[] cbuf = new char[1024]; int readden = reader.read(cbuf); while (readden >= 0) { sb.append(cbuf, 0, readden); readden = reader.read(cbuf); } return sb.toString(); } }
public Charset getEncoding() { return Charset.forName(((UnicodeReader) this.stream).getEncoding()); }
/** * Parse the only YAML document in a stream and produce the corresponding * Java object. * * @param io * data to load from (BOM is respected to detect encoding and removed from the data) * @param <T> * the class of the instance to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T load(InputStream io) { return (T) loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class); }
private static String readYamlFileToString(File yamlFile) throws IOException { // using UnicodeReader to read the correct encoding according to BOM try (UnicodeReader reader = new UnicodeReader(new FileInputStream(yamlFile))) { StringBuilder sb = new StringBuilder(); char[] cbuf = new char[1024]; int readden = reader.read(cbuf); while(readden >= 0) { sb.append(cbuf, 0, readden); readden = reader.read(cbuf); } return sb.toString(); } }
public void close() throws IOException { init(); internalIn2.close(); }
/** * Parse the only YAML document in a stream and produce the corresponding * Java object. * * @param <T> * Class is defined by the second argument * @param input * data to load from (BOM is respected to detect encoding and removed from the data) * @param type * Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T loadAs(InputStream input, Class<T> type) { return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type); }
private static String readYamlFileToString(File yamlFile) throws IOException { // using UnicodeReader to read the correct encoding according to BOM try (UnicodeReader reader = new UnicodeReader(new FileInputStream(yamlFile))) { StringBuilder sb = new StringBuilder(); char[] cbuf = new char[1024]; int readden = reader.read(cbuf); while(readden >= 0) { sb.append(cbuf, 0, readden); readden = reader.read(cbuf); } return sb.toString(); } }
public int read(char[] cbuf, int off, int len) throws IOException { init(); return internalIn2.read(cbuf, off, len); } }
private boolean process(MatchCallback callback, Yaml yaml, Resource resource) { int count = 0; try { if (logger.isDebugEnabled()) { logger.debug("Loading from YAML: " + resource); } Reader reader = new UnicodeReader(resource.getInputStream()); try { for (Object object : yaml.loadAll(reader)) { if (object != null && process(asMap(object), callback)) { count++; if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND) { break; } } } if (logger.isDebugEnabled()) { logger.debug("Loaded " + count + " document" + (count > 1 ? "s" : "") + " from YAML resource: " + resource); } } finally { reader.close(); } } catch (IOException ex) { handleProcessError(resource, ex); } return (count > 0); }
private static String readYamlFileToString(File yamlFile) throws IOException { // using UnicodeReader to read the correct encoding according to BOM try (UnicodeReader reader = new UnicodeReader(new FileInputStream(yamlFile))) { StringBuilder sb = new StringBuilder(); char[] cbuf = new char[1024]; int readden = reader.read(cbuf); while(readden >= 0) { sb.append(cbuf, 0, readden); readden = reader.read(cbuf); } return sb.toString(); } }
public int read(char[] cbuf, int off, int len) throws IOException { init(); return internalIn2.read(cbuf, off, len); } }
/** * Loads the configuration file. * * @throws java.io.IOException on load error */ public void load() throws IOException { try (InputStream stream = getInputStream()) { if (stream == null) throw new IOException("Stream is null!"); read(yaml.load(new UnicodeReader(stream))); } catch (YAMLProcessorException e) { root = new LinkedHashMap<>(); } }
private static String readYamlFileToString(File yamlFile) throws IOException { // using UnicodeReader to read the correct encoding according to BOM try (UnicodeReader reader = new UnicodeReader(new FileInputStream(yamlFile))) { StringBuffer sb = new StringBuffer(); char[] cbuf = new char[1024]; int readden = reader.read(cbuf); while (readden >= 0) { sb.append(cbuf, 0, readden); readden = reader.read(cbuf); } return sb.toString(); } }
public int read(char[] cbuf, int off, int len) throws IOException { init(); return internalIn2.read(cbuf, off, len); } }
private boolean process(MatchCallback callback, Yaml yaml, Resource resource) { int count = 0; try { if (logger.isDebugEnabled()) { logger.debug("Loading from YAML: " + resource); } Reader reader = new UnicodeReader(resource.getInputStream()); try { for (Object object : yaml.loadAll(reader)) { if (object != null && process(asMap(object), callback)) { count++; if (this.resolutionMethod == ResolutionMethod.FIRST_FOUND) { break; } } } if (logger.isDebugEnabled()) { logger.debug("Loaded " + count + " document" + (count > 1 ? "s" : "") + " from YAML resource: " + resource); } } finally { reader.close(); } } catch (IOException ex) { handleProcessError(resource, ex); } return (count > 0); }
public void close() throws IOException { init(); internalIn2.close(); }