com.dslplatform.json
Class JsonStreamReader<TContext>
java.lang.Object
com.dslplatform.json.JsonReader<TContext>
com.dslplatform.json.JsonStreamReader<TContext>
- Type Parameters:
TContext
- context passed to deserialized object instances
public final class JsonStreamReader<TContext>
- extends JsonReader<TContext>
Object for processing JSON from InputStream.
DSL-JSON works on byte level (instead of char level).
Deserialized instances can obtain TContext information provided with this reader.
Stream reader works by partially processing JSON in chunks.
Methods inherited from class com.dslplatform.json.JsonReader |
calcHash, checkArrayEnd, deserializeCollection, deserializeCollection, deserializeCollection, deserializeCollection, deserializeNullableCollection, deserializeNullableCollection, deserializeNullableCollection, deserializeNullableCollection, fillName, getCurrentIndex, getLastName, getNextToken, getTokenStart, last, length, positionInStream, positionInStream, readKey, readNext, readNumber, readSimpleQuote, readSimpleString, readString, scanNumber, skip, toString, wasFalse, wasLastName, wasNull, wasTrue |
JsonStreamReader
public JsonStreamReader(InputStream stream,
byte[] buffer,
TContext context)
throws IOException
- Create reusable stream reader.
Prefer creating stream reader through DslJson#newReader since it will pass several arguments (such as key/string value cache)
First chunk will be populated.
First byte will not be read.
It will allocate new char[64] for string buffer
- Parameters:
stream
- input stream to read frombuffer
- buffer to hold chunk of streamcontext
- available context
- Throws:
IOException
- unable to read from stream
readFully
public static int readFully(byte[] buffer,
InputStream stream,
int offset)
throws IOException
- Populate buffer until the end of buffer or stream.
- Parameters:
buffer
- buffer to fillstream
- stream to readoffset
- populate buffer after specified offset
- Returns:
- how many bytes have been read
- Throws:
IOException
- unable to read from stream
reset
public void reset(InputStream stream)
throws IOException
- Prepare JsonStreamReader for processing another stream.
First chunk will be populated.
First byte will not be read.
- Parameters:
stream
- new stream to process
- Throws:
IOException
- unable to read from stream
read
public byte read()
throws IOException
- Read next byte from JSON input (buffer/stream).
If buffer has been processed, fill the buffer with next chunk;
otherwise get next byte from the buffer
- Overrides:
read
in class JsonReader<TContext>
- Returns:
- next byte to process
- Throws:
IOException
- unable to read from stream
readBase64
public byte[] readBase64()
throws IOException
- Overrides:
readBase64
in class JsonReader<TContext>
- Throws:
IOException
iterateOver
public <T> Iterator<T> iterateOver(JsonReader.ReadObject<T> reader)
throws IOException
- Throws:
IOException
iterateOver
public <T extends JsonObject> Iterator<T> iterateOver(JsonReader.ReadJsonObject<T> reader)
throws IOException
- Throws:
IOException
Copyright © 2017. All rights reserved.