|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.dslplatform.json.JsonReader<TContext>
TContext - context passed to deserialized object instancespublic final class JsonReader<TContext>
Object for processing JSON from byte[] and InputStream. DSL-JSON works on byte level (instead of char level). Deserialized instances can obtain TContext information provided with this reader.
JsonReader can be reused by calling process methods.
| Nested Class Summary | |
|---|---|
static interface |
JsonReader.BindObject<T>
Existing instances can be provided as target for deserialization. |
static class |
JsonReader.DoublePrecision
|
static class |
JsonReader.ErrorInfo
|
static interface |
JsonReader.ReadJsonObject<T extends JsonObject>
|
static interface |
JsonReader.ReadObject<T>
Custom objects can be deserialized based on the implementation specified through this interface. |
static class |
JsonReader.UnknownNumberParsing
|
| Field Summary | |
|---|---|
protected byte[] |
buffer
|
protected char[] |
chars
|
TContext |
context
|
protected int |
doubleLengthLimit
|
protected JsonReader.DoublePrecision |
doublePrecision
|
protected JsonReader.ErrorInfo |
errorInfo
|
protected int |
maxNumberDigits
|
protected JsonReader.UnknownNumberParsing |
unknownNumbers
|
| Constructor Summary | |
|---|---|
JsonReader(byte[] buffer,
int length,
TContext context)
Deprecated. |
|
JsonReader(byte[] buffer,
int length,
TContext context,
char[] tmp)
Deprecated. |
|
JsonReader(byte[] buffer,
int length,
TContext context,
char[] tmp,
StringCache keyCache,
StringCache valuesCache)
Deprecated. |
|
JsonReader(byte[] buffer,
TContext context)
Deprecated. |
|
JsonReader(byte[] buffer,
TContext context,
char[] tmp)
Deprecated. |
|
JsonReader(byte[] buffer,
TContext context,
StringCache keyCache,
StringCache valuesCache)
Deprecated. |
|
| Method Summary | ||
|---|---|---|
StringBuffer |
appendString(StringBuffer buffer)
|
|
StringBuilder |
appendString(StringBuilder builder)
|
|
int |
calcHash()
|
|
int |
calcWeakHash()
|
|
void |
checkArrayEnd()
Check if the last read token is an array end |
|
void |
checkObjectEnd()
Check if the last read token is an object end |
|
void |
comma()
Will advance to next token and check if it's comma |
|
|
deserializeCollection(JsonReader.ReadJsonObject<T> readObject)
|
|
|
deserializeCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res)
|
|
|
deserializeCollection(JsonReader.ReadObject<S> readObject)
|
|
|
deserializeCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res)
|
|
|
deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject)
|
|
|
deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res)
|
|
|
deserializeNullableCollection(JsonReader.ReadObject<S> readObject)
|
|
|
deserializeNullableCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res)
|
|
void |
endArray()
Will advance to next token and check if it's array end |
|
void |
endObject()
Will advance to next token and check it it's object end |
|
int |
fillName()
|
|
int |
fillNameWeakHash()
|
|
int |
getCurrentIndex()
|
|
int |
getLastHash()
|
|
String |
getLastName()
|
|
byte |
getNextToken()
Read next token (byte) from input JSON. |
|
int |
getTokenStart()
|
|
|
iterateOver(JsonReader.ReadJsonObject<T> reader)
|
|
|
iterateOver(JsonReader.ReadObject<T> reader)
|
|
byte |
last()
Which was last byte read from the JSON input. |
|
int |
length()
Valid length of the input buffer. |
|
ParsingException |
newParseError(String description)
|
|
ParsingException |
newParseError(String description,
int positionOffset)
|
|
ParsingException |
newParseErrorAt(String description,
int positionOffset)
|
|
ParsingException |
newParseErrorAt(String description,
int positionOffset,
Exception cause)
|
|
ParsingException |
newParseErrorFormat(String shortDescription,
int positionOffset,
String longDescriptionFormat,
Object... arguments)
|
|
ParsingException |
newParseErrorWith(String shortDescription,
int positionOffset,
String longDescriptionPrefix,
String longDescriptionMessage,
Object argument,
String longDescriptionSuffix)
|
|
ParsingException |
newParseErrorWith(String description,
Object argument)
|
|
|
next(Class<T> manifest)
Will advance to next token and read the JSON into specified type |
|
|
next(Class<T> manifest,
T instance)
Will advance to next token and bind the JSON to provided instance |
|
|
next(JsonReader.BindObject<T> binder,
T instance)
Will advance to next token and bind the JSON to provided instance |
|
|
next(JsonReader.ReadObject<T> reader)
Will advance to next token and read the JSON into specified type |
|
String |
positionDescription()
|
|
String |
positionDescription(int offset)
|
|
long |
positionInStream()
|
|
long |
positionInStream(int offset)
|
|
JsonReader<TContext> |
process(byte[] newBuffer,
int newLength)
Bind byte[] buffer for processing. |
|
JsonReader<TContext> |
process(InputStream stream)
Bind input stream for processing. |
|
byte |
read()
Read next byte from the JSON input. |
|
|
readArray(JsonReader.ReadObject<T> readObject,
T[] emptyArray)
|
|
byte[] |
readBase64()
|
|
|
readCollection(JsonReader.ReadObject<T> readObject)
|
|
String |
readKey()
Read key value of JSON input. |
|
|
readMap(JsonReader.ReadObject<K> readKey,
JsonReader.ReadObject<V> readValue)
|
|
String |
readNext()
Deprecated. |
|
char[] |
readNumber()
Deprecated. |
|
|
readSet(JsonReader.ReadObject<T> readObject)
|
|
char[] |
readSimpleQuote()
Read simple "ascii string" into temporary buffer. |
|
String |
readSimpleString()
Read simple ascii string. |
|
String |
readString()
Read string from JSON input. |
|
void |
reset(InputStream stream)
Deprecated. |
|
int |
scanNumber()
|
|
void |
semicolon()
Will advance to next token and check if it's semicolon |
|
byte |
skip()
Skip to next non-whitespace token (byte) Will not allocate memory while skipping over JSON input. |
|
void |
startArray()
Will advance to next token and check if it's array start |
|
void |
startAttribute(String name)
|
|
void |
startObject()
Will advance to next token and check if it's object start |
|
String |
toString()
|
|
boolean |
wasFalse()
Checks if 'false' value is at current position. |
|
boolean |
wasLastName(byte[] name)
|
|
boolean |
wasLastName(String name)
|
|
boolean |
wasNull()
Checks if 'null' value is at current position. |
|
boolean |
wasTrue()
Checks if 'true' value is at current position. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final TContext context
protected byte[] buffer
protected char[] chars
protected final JsonReader.ErrorInfo errorInfo
protected final JsonReader.DoublePrecision doublePrecision
protected final int doubleLengthLimit
protected final JsonReader.UnknownNumberParsing unknownNumbers
protected final int maxNumberDigits
| Constructor Detail |
|---|
@Deprecated
public JsonReader(byte[] buffer,
@Nullable
TContext context)
buffer - input JSONcontext - context
@Deprecated
public JsonReader(byte[] buffer,
@Nullable
TContext context,
@Nullable
StringCache keyCache,
@Nullable
StringCache valuesCache)
@Deprecated
public JsonReader(byte[] buffer,
TContext context,
char[] tmp)
@Deprecated
public JsonReader(byte[] buffer,
int length,
TContext context)
@Deprecated
public JsonReader(byte[] buffer,
int length,
TContext context,
char[] tmp)
@Deprecated
public JsonReader(byte[] buffer,
int length,
@Nullable
TContext context,
char[] tmp,
@Nullable
StringCache keyCache,
@Nullable
StringCache valuesCache)
| Method Detail |
|---|
@Deprecated
public final void reset(InputStream stream)
throws IOException
stream - process stream
IOException - error reading from stream
public final JsonReader<TContext> process(@Nullable
InputStream stream)
throws IOException
stream - set input stream
IOException - unable to read from stream
public final JsonReader<TContext> process(@Nullable
byte[] newBuffer,
int newLength)
newBuffer - new buffer to use for processingnewLength - length of buffer which can be used
public final int length()
public String toString()
toString in class Object
public final byte read()
throws IOException
IOException - when end of JSON inputpublic final byte last()
public String positionDescription()
public String positionDescription(int offset)
public final ParsingException newParseError(String description)
public final ParsingException newParseError(String description,
int positionOffset)
public final ParsingException newParseErrorAt(String description,
int positionOffset)
public final ParsingException newParseErrorAt(String description,
int positionOffset,
Exception cause)
public final ParsingException newParseErrorFormat(String shortDescription,
int positionOffset,
String longDescriptionFormat,
Object... arguments)
public final ParsingException newParseErrorWith(String description,
@Nullable
Object argument)
public final ParsingException newParseErrorWith(String shortDescription,
int positionOffset,
String longDescriptionPrefix,
String longDescriptionMessage,
@Nullable
Object argument,
String longDescriptionSuffix)
public final int getTokenStart()
public final int getCurrentIndex()
@Deprecated public final char[] readNumber()
public final int scanNumber()
public final String readSimpleString()
throws ParsingException
ParsingException - unable to parse string
public final char[] readSimpleQuote()
throws ParsingException
ParsingException - unable to parse string
public final String readString()
throws IOException
String value must start and end with a double quote (").
IOException - error reading string input
public final StringBuilder appendString(StringBuilder builder)
throws IOException
IOException
public final StringBuffer appendString(StringBuffer buffer)
throws IOException
IOException
public final byte getNextToken()
throws IOException
IOException - unable to get next byte (end of stream, ...)public final long positionInStream()
public final long positionInStream(int offset)
public final int fillName()
throws IOException
IOException
public final int fillNameWeakHash()
throws IOException
IOException
public final int calcHash()
throws IOException
IOException
public final int calcWeakHash()
throws IOException
IOExceptionpublic final int getLastHash()
public final boolean wasLastName(String name)
public final boolean wasLastName(byte[] name)
public final String getLastName()
throws IOException
IOException
public final byte skip()
throws IOException
IOException - unable to read next byte (end of stream, invalid JSON, ...)
@Deprecated
public String readNext()
throws IOException
IOException - throws if invalid JSON detected
public final byte[] readBase64()
throws IOException
IOException
public final String readKey()
throws IOException
IOException - unable to parse string input
public final boolean wasNull()
throws ParsingException
ParsingException - invalid 'null' value detected
public final boolean wasTrue()
throws ParsingException
ParsingException - invalid 'true' value detected
public final boolean wasFalse()
throws ParsingException
ParsingException - invalid 'false' value detected
public final void comma()
throws IOException
IOException - it's not comma
public final void semicolon()
throws IOException
IOException - it's not semicolon
public final void startArray()
throws IOException
IOException - it's not array start
public final void endArray()
throws IOException
IOException - it's not array end
public final void startObject()
throws IOException
IOException - it's not object start
public final void endObject()
throws IOException
IOException - it's not object end
public final void startAttribute(String name)
throws IOException
IOException
public final void checkArrayEnd()
throws IOException
IOException - it's not array end
public final void checkObjectEnd()
throws IOException
IOException - it's not object end
@Nullable
public final <T> T next(Class<T> manifest)
throws IOException
T - typemanifest - type to read into
IOException - unable to process JSON
@Nullable
public final <T> T next(JsonReader.ReadObject<T> reader)
throws IOException
T - typereader - reader to use
IOException - unable to process JSON
@Nullable
public final <T> T next(Class<T> manifest,
T instance)
throws IOException
T - typemanifest - type to read intoinstance - instance to bind
IOException - unable to process JSON
@Nullable
public final <T> T next(JsonReader.BindObject<T> binder,
T instance)
throws IOException
T - typebinder - binder to useinstance - instance to bind
IOException - unable to process JSON
@Nullable
public final <T> ArrayList<T> readCollection(JsonReader.ReadObject<T> readObject)
throws IOException
IOException
@Nullable
public final <T> LinkedHashSet<T> readSet(JsonReader.ReadObject<T> readObject)
throws IOException
IOException
@Nullable
public final <K,V> LinkedHashMap<K,V> readMap(JsonReader.ReadObject<K> readKey,
JsonReader.ReadObject<V> readValue)
throws IOException
IOException
@Nullable
public final <T> T[] readArray(JsonReader.ReadObject<T> readObject,
T[] emptyArray)
throws IOException
IOException
public final <T,S extends T> ArrayList<T> deserializeCollection(JsonReader.ReadObject<S> readObject)
throws IOException
IOException
public final <T,S extends T> void deserializeCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res)
throws IOException
IOException
public final <T,S extends T> ArrayList<T> deserializeNullableCollection(JsonReader.ReadObject<S> readObject)
throws IOException
IOException
public final <T,S extends T> void deserializeNullableCollection(JsonReader.ReadObject<S> readObject,
Collection<T> res)
throws IOException
IOException
public final <T extends JsonObject> ArrayList<T> deserializeCollection(JsonReader.ReadJsonObject<T> readObject)
throws IOException
IOException
public final <T extends JsonObject> void deserializeCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res)
throws IOException
IOException
public final <T extends JsonObject> ArrayList<T> deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject)
throws IOException
IOException
public final <T extends JsonObject> void deserializeNullableCollection(JsonReader.ReadJsonObject<T> readObject,
Collection<T> res)
throws IOException
IOExceptionpublic final <T> Iterator<T> iterateOver(JsonReader.ReadObject<T> reader)
public final <T extends JsonObject> Iterator<T> iterateOver(JsonReader.ReadJsonObject<T> reader)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||