private boolean ensureEnoughData(int size) { if (!eof && pointer + size >= dataLength) { update(); } return (this.pointer + size) < dataLength; }
/** * Returns true if the next thing on the reader is a directive, given that * the leading '%' has already been checked. * * @see <a href="http://www.yaml.org/spec/1.1/#id864824"></a> */ private boolean checkDirective() { // DIRECTIVE: ^ '%' ... // The '%' indicator is already checked. return reader.getColumn() == 0; }
/** * Peek the next index-th code point * * @param index to peek * @return the next index-th code point */ public int peek(int index) { return (ensureEnoughData(index)) ? dataWindow[pointer + index] : '\0'; }
/** * 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); }
/** * 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 YAMLParser(IOContext ctxt, BufferRecycler br, int parserFeatures, int formatFeatures, ObjectCodec codec, Reader reader) { super(ctxt, parserFeatures); _objectCodec = codec; _formatFeatures = formatFeatures; _reader = reader; _yamlParser = new ParserImpl(new StreamReader(reader)); }
/** * Returns true if the next thing on the reader is a block token. */ private boolean checkBlockEntry() { // BLOCK-ENTRY: '-' (' '|'\n') return Constant.NULL_BL_T_LINEBR.has(reader.peek(1)); }
public int read(char[] cbuf, int off, int len) throws IOException { init(); return internalIn2.read(cbuf, off, len); } }
/** * prefix(length) immediately followed by forward(length) * @param length amount of characters to get * @return the next length code points */ public String prefixForward(int length) { final String prefix = prefix(length); this.pointer += length; this.index += length; // prefix never contains new line characters this.column += length; return prefix; }
public void forward() { forward(1); }
/** * 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); }
/** * Parse the only YAML document in a stream and produce the corresponding * Java object. * * @param io * data to load from (BOM must not be present) * @param <T> * the class of the instance to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T load(Reader io) { return (T) loadFromReader(new StreamReader(io), Object.class); }
/** * Returns true if the next thing on the reader is a key token. */ private boolean checkKey() { // KEY(flow context): '?' if (this.flowLevel != 0) { return true; } else { // KEY(block context): '?' (' '|'\n') return Constant.NULL_BL_T_LINEBR.has(reader.peek(1)); } }
public void close() throws IOException { init(); internalIn2.close(); }
private boolean ensureEnoughData() { return ensureEnoughData(0); }
/** * Parse the only YAML document in a String and produce the corresponding * Java object. (Because the encoding in known BOM is not respected.) * * @param yaml * YAML data to load from (BOM must not be present) * @param <T> * the class of the instance to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T load(String yaml) { return (T) loadFromReader(new StreamReader(yaml), Object.class); }
/** * Returns true if the next thing on the reader is a value token. */ private boolean checkValue() { // VALUE(flow context): ':' if (flowLevel != 0) { return true; } else { // VALUE(block context): ':' (' '|'\n') return Constant.NULL_BL_T_LINEBR.has(reader.peek(1)); } }
public int peek() { return (ensureEnoughData()) ? dataWindow[pointer] : '\0'; }
/** * Parse the only YAML document in a String and produce the corresponding * Java object. (Because the encoding in known BOM is not respected.) * * @param <T> * Class is defined by the second argument * @param yaml * YAML data to load from (BOM must not be present) * @param type * Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T loadAs(String yaml, Class<T> type) { return (T) loadFromReader(new StreamReader(yaml), type); }
/** * Parse the only YAML document in a stream and produce the corresponding * Java object. * * @param <T> * Class is defined by the second argument * @param io * data to load from (BOM must not be present) * @param type * Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") public <T> T loadAs(Reader io, Class<T> type) { return (T) loadFromReader(new StreamReader(io), type); }