Debian Codegraph @

src/main/java/com/fasterxml/jackson/dataformat/smile/async/NonBlockingInputFeeder.java

raw
1 package com.fasterxml.jackson.dataformat.smile.async;
2
3 import java.io.IOException;
4
5 /**
6 * Interface used by non-blocking {@link com.fasterxml.jackson.core.JsonParser}
7 * to get more input to parse.
8 * It is accessed by entity that feeds content to parse; at any given point
9 * only one chunk of content can be processed so caller has to take care to
10 * only feed more content when existing content has been parsed (which occurs
11 * when parser's <code>nextToken</code> is called). Once application using
12 * non-blocking parser has no more data to feed it should call
13 * {@link #endOfInput} to indicate end of logical input stream.
14 *
15 * @author Tatu Saloranta
16 */
17 public interface NonBlockingInputFeeder
18 {
19 /**
20 * Method called to check whether it is ok to feed more data: parser returns true
21 * if it has no more content to parse (and it is ok to feed more); otherwise false
22 * (and no data should yet be fed).
23 */
24 public boolean needMoreInput();
25
26 /**
27 * Method that can be called to feed more data, if (and only if)
28 * {@link #needMoreInput} returns true.
29 *
30 * @param data Byte array that contains data to feed: caller must ensure data remains
31 * stable until it is fully processed (which is true when {@link #needMoreInput}
32 * returns true)
33 * @param offset Offset within array where input data to process starts
34 * @param len Length of input data within array to process.
35 *
36 * @throws IOException if the state is such that this method should not be called
37 * (has not yet consumed existing input data, or has been marked as closed)
38 */
39 public void feedInput(byte[] data, int offset, int len) throws IOException;
40
41 /**
42 * Method that should be called after last chunk of data to parse has been fed
43 * (with {@link #feedInput}); can be called regardless of what {@link #needMoreInput}
44 * returns. After calling this method, no more data can be fed; and parser assumes
45 * no more data will be available.
46 */
47 public void endOfInput();
48 }