Package com.jsoniter
Class JsonIterator
- java.lang.Object
-
- com.jsoniter.JsonIterator
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class JsonIterator extends java.lang.Object implements java.io.Closeable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JsonIterator.ReadArrayCallback
static interface
JsonIterator.ReadObjectCallback
-
Field Summary
Fields Modifier and Type Field Description (package private) byte[]
buf
Config
configCache
(package private) java.lang.Object
existingObject
private static JsonIterator.ReadArrayCallback
fillArray
private static JsonIterator.ReadObjectCallback
fillObject
(package private) int
head
(package private) java.io.InputStream
in
private static boolean
isStreamingEnabled
(package private) char[]
reusableChars
(package private) Slice
reusableSlice
(package private) int
skipStartedAt
(package private) int
tail
(package private) java.util.Map<java.lang.String,java.lang.Object>
tempObjects
(package private) static ValueType[]
valueTypes
-
Constructor Summary
Constructors Modifier Constructor Description JsonIterator()
private
JsonIterator(java.io.InputStream in, byte[] buf, int head, int tail)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
currentBuffer()
private Config
currentConfig()
static Any
deserialize(byte[] input)
static <T> T
deserialize(byte[] input, TypeLiteral<T> typeLiteral)
static <T> T
deserialize(byte[] input, java.lang.Class<T> clazz)
static Any
deserialize(Config config, byte[] input)
static <T> T
deserialize(Config config, byte[] input, TypeLiteral<T> typeLiteral)
static <T> T
deserialize(Config config, byte[] input, java.lang.Class<T> clazz)
static Any
deserialize(Config config, java.lang.String input)
static <T> T
deserialize(Config config, java.lang.String input, TypeLiteral<T> typeLiteral)
static <T> T
deserialize(Config config, java.lang.String input, java.lang.Class<T> clazz)
static Any
deserialize(java.lang.String input)
static <T> T
deserialize(java.lang.String input, TypeLiteral<T> typeLiteral)
static <T> T
deserialize(java.lang.String input, java.lang.Class<T> clazz)
static void
enableStreamingSupport()
private static int
findLastNotSpacePos(byte[] input)
static JsonIterator
parse(byte[] buf)
static JsonIterator
parse(byte[] buf, int head, int tail)
static JsonIterator
parse(Slice slice)
static JsonIterator
parse(java.io.InputStream in, int bufSize)
static JsonIterator
parse(java.lang.String str)
java.lang.Object
read()
<T> T
read(TypeLiteral<T> typeLiteral)
<T> T
read(TypeLiteral<T> typeLiteral, T existingObject)
try to bind to existing object, returned object might not the same instance<T> T
read(java.lang.Class<T> clazz)
java.lang.Object
read(java.lang.reflect.Type type)
<T> T
read(T existingObject)
try to bind to existing object, returned object might not the same instanceAny
readAny()
boolean
readArray()
boolean
readArrayCB(JsonIterator.ReadArrayCallback callback, java.lang.Object attachment)
java.math.BigDecimal
readBigDecimal()
java.math.BigInteger
readBigInteger()
boolean
readBoolean()
double
readDouble()
float
readFloat()
int
readInt()
long
readLong()
boolean
readNull()
java.lang.String
readNumberAsString()
java.lang.String
readObject()
void
readObjectCB(JsonIterator.ReadObjectCallback cb, java.lang.Object attachment)
short
readShort()
java.lang.String
readString()
Slice
readStringAsSlice()
JsonException
reportError(java.lang.String op, java.lang.String msg)
void
reset(byte[] buf)
void
reset(byte[] buf, int head, int tail)
void
reset(Slice value)
void
reset(java.io.InputStream in)
static void
setMode(DecodingMode mode)
void
skip()
(package private) void
unreadByte()
ValueType
whatIsNext()
-
-
-
Field Detail
-
configCache
public Config configCache
-
isStreamingEnabled
private static boolean isStreamingEnabled
-
valueTypes
static final ValueType[] valueTypes
-
in
java.io.InputStream in
-
buf
byte[] buf
-
head
int head
-
tail
int tail
-
skipStartedAt
int skipStartedAt
-
tempObjects
java.util.Map<java.lang.String,java.lang.Object> tempObjects
-
reusableSlice
final Slice reusableSlice
-
reusableChars
char[] reusableChars
-
existingObject
java.lang.Object existingObject
-
fillArray
private static final JsonIterator.ReadArrayCallback fillArray
-
fillObject
private static final JsonIterator.ReadObjectCallback fillObject
-
-
Method Detail
-
parse
public static JsonIterator parse(java.io.InputStream in, int bufSize)
-
parse
public static JsonIterator parse(byte[] buf)
-
parse
public static JsonIterator parse(byte[] buf, int head, int tail)
-
parse
public static JsonIterator parse(java.lang.String str)
-
parse
public static JsonIterator parse(Slice slice)
-
reset
public final void reset(byte[] buf)
-
reset
public final void reset(byte[] buf, int head, int tail)
-
reset
public final void reset(Slice value)
-
reset
public final void reset(java.io.InputStream in)
-
close
public final void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
unreadByte
final void unreadByte()
-
reportError
public final JsonException reportError(java.lang.String op, java.lang.String msg)
-
currentBuffer
public final java.lang.String currentBuffer()
-
readNull
public final boolean readNull() throws java.io.IOException
- Throws:
java.io.IOException
-
readBoolean
public final boolean readBoolean() throws java.io.IOException
- Throws:
java.io.IOException
-
readShort
public final short readShort() throws java.io.IOException
- Throws:
java.io.IOException
-
readInt
public final int readInt() throws java.io.IOException
- Throws:
java.io.IOException
-
readLong
public final long readLong() throws java.io.IOException
- Throws:
java.io.IOException
-
readArray
public final boolean readArray() throws java.io.IOException
- Throws:
java.io.IOException
-
readNumberAsString
public java.lang.String readNumberAsString() throws java.io.IOException
- Throws:
java.io.IOException
-
readArrayCB
public final boolean readArrayCB(JsonIterator.ReadArrayCallback callback, java.lang.Object attachment) throws java.io.IOException
- Throws:
java.io.IOException
-
readString
public final java.lang.String readString() throws java.io.IOException
- Throws:
java.io.IOException
-
readStringAsSlice
public final Slice readStringAsSlice() throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
public final java.lang.String readObject() throws java.io.IOException
- Throws:
java.io.IOException
-
readObjectCB
public final void readObjectCB(JsonIterator.ReadObjectCallback cb, java.lang.Object attachment) throws java.io.IOException
- Throws:
java.io.IOException
-
readFloat
public final float readFloat() throws java.io.IOException
- Throws:
java.io.IOException
-
readDouble
public final double readDouble() throws java.io.IOException
- Throws:
java.io.IOException
-
readBigDecimal
public final java.math.BigDecimal readBigDecimal() throws java.io.IOException
- Throws:
java.io.IOException
-
readBigInteger
public final java.math.BigInteger readBigInteger() throws java.io.IOException
- Throws:
java.io.IOException
-
readAny
public final Any readAny() throws java.io.IOException
- Throws:
java.io.IOException
-
read
public final java.lang.Object read() throws java.io.IOException
- Throws:
java.io.IOException
-
read
public final <T> T read(T existingObject) throws java.io.IOException
try to bind to existing object, returned object might not the same instance- Type Parameters:
T
- object type- Parameters:
existingObject
- the object instance to reuse- Returns:
- data binding result, might not be the same object
- Throws:
java.io.IOException
- if I/O went wrong
-
currentConfig
private Config currentConfig()
-
read
public final <T> T read(TypeLiteral<T> typeLiteral, T existingObject) throws java.io.IOException
try to bind to existing object, returned object might not the same instance- Type Parameters:
T
- object type- Parameters:
typeLiteral
- the type objectexistingObject
- the object instance to reuse- Returns:
- data binding result, might not be the same object
- Throws:
java.io.IOException
- if I/O went wrong
-
read
public final <T> T read(java.lang.Class<T> clazz) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public final <T> T read(TypeLiteral<T> typeLiteral) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public final java.lang.Object read(java.lang.reflect.Type type) throws java.io.IOException
- Throws:
java.io.IOException
-
whatIsNext
public ValueType whatIsNext() throws java.io.IOException
- Throws:
java.io.IOException
-
skip
public void skip() throws java.io.IOException
- Throws:
java.io.IOException
-
deserialize
public static final <T> T deserialize(Config config, java.lang.String input, java.lang.Class<T> clazz)
-
deserialize
public static final <T> T deserialize(java.lang.String input, java.lang.Class<T> clazz)
-
deserialize
public static final <T> T deserialize(Config config, java.lang.String input, TypeLiteral<T> typeLiteral)
-
deserialize
public static final <T> T deserialize(java.lang.String input, TypeLiteral<T> typeLiteral)
-
deserialize
public static final <T> T deserialize(Config config, byte[] input, java.lang.Class<T> clazz)
-
deserialize
public static final <T> T deserialize(byte[] input, java.lang.Class<T> clazz)
-
deserialize
public static final <T> T deserialize(Config config, byte[] input, TypeLiteral<T> typeLiteral)
-
deserialize
public static final <T> T deserialize(byte[] input, TypeLiteral<T> typeLiteral)
-
deserialize
public static final Any deserialize(java.lang.String input)
-
deserialize
public static final Any deserialize(byte[] input)
-
findLastNotSpacePos
private static int findLastNotSpacePos(byte[] input)
-
setMode
public static void setMode(DecodingMode mode)
-
enableStreamingSupport
public static void enableStreamingSupport()
-
-