Package com.dropbox.core.json
Class JsonReader<T>
- java.lang.Object
-
- com.dropbox.core.json.JsonReader<T>
-
- Direct Known Subclasses:
DbxDelta.Entry.Reader
,DbxDelta.Reader
,DbxDeltaC.Entry.Reader
,DbxDeltaC.Reader
,DbxEntry.WithChildrenC.Reader
,DbxEntry.WithChildrenC.ReaderMaybeDeleted
,JsonArrayReader
public abstract class JsonReader<T> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonReader.FieldMapping
If you're implementing aJsonReader
for a JSON object, you can use this to map field names to a number you canswitch
on to efficiently locate assign a field.static class
JsonReader.FileLoadException
-
Field Summary
Fields Modifier and Type Field Description static JsonReader<byte[]>
BinaryReader
static JsonReader<java.lang.Boolean>
BooleanReader
static JsonReader<java.lang.Float>
Float32Reader
static JsonReader<java.lang.Double>
Float64Reader
static JsonReader<java.lang.Integer>
Int32Reader
static JsonReader<java.lang.Long>
Int64Reader
static JsonReader<java.lang.String>
StringReader
static JsonReader<java.lang.Long>
UInt32Reader
static JsonReader<java.lang.Long>
UInt64Reader
static JsonReader<java.lang.Long>
UnsignedLongReader
static JsonReader<java.lang.Object>
VoidReader
-
Constructor Summary
Constructors Constructor Description JsonReader()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.core.JsonLocation
expectArrayEnd(com.fasterxml.jackson.core.JsonParser parser)
static com.fasterxml.jackson.core.JsonLocation
expectArrayStart(com.fasterxml.jackson.core.JsonParser parser)
static void
expectObjectEnd(com.fasterxml.jackson.core.JsonParser parser)
static com.fasterxml.jackson.core.JsonLocation
expectObjectStart(com.fasterxml.jackson.core.JsonParser parser)
static boolean
isArrayEnd(com.fasterxml.jackson.core.JsonParser parser)
static boolean
isArrayStart(com.fasterxml.jackson.core.JsonParser parser)
static com.fasterxml.jackson.core.JsonToken
nextToken(com.fasterxml.jackson.core.JsonParser parser)
A wrapper around 'JsonParser.nextToken' that throws our own betterJsonReadException
instead of Jackson'sJsonParseException
.abstract T
read(com.fasterxml.jackson.core.JsonParser parser)
static boolean
readBoolean(com.fasterxml.jackson.core.JsonParser parser)
static double
readDouble(com.fasterxml.jackson.core.JsonParser parser)
static <T> T
readEnum(com.fasterxml.jackson.core.JsonParser parser, java.util.HashMap<java.lang.String,T> values, T catch_all)
T
readField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, java.lang.Object v)
T
readFields(com.fasterxml.jackson.core.JsonParser parser)
T
readFromFile(java.io.File file)
T
readFromFile(java.lang.String filePath)
T
readFromTags(java.lang.String[] tags, com.fasterxml.jackson.core.JsonParser parser)
T
readFully(byte[] utf8Body)
T
readFully(com.fasterxml.jackson.core.JsonParser parser)
T
readFully(java.io.InputStream utf8Body)
T
readFully(java.lang.String body)
T
readOptional(com.fasterxml.jackson.core.JsonParser parser)
static java.lang.String[]
readTags(com.fasterxml.jackson.core.JsonParser parser)
Helper to read and parse the optional ".tag" field.static long
readUnsignedLong(com.fasterxml.jackson.core.JsonParser parser)
static long
readUnsignedLongField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, long v)
static void
skipValue(com.fasterxml.jackson.core.JsonParser parser)
void
validate(T value)
-
-
-
Field Detail
-
UnsignedLongReader
public static final JsonReader<java.lang.Long> UnsignedLongReader
-
Int64Reader
public static final JsonReader<java.lang.Long> Int64Reader
-
Int32Reader
public static final JsonReader<java.lang.Integer> Int32Reader
-
UInt64Reader
public static final JsonReader<java.lang.Long> UInt64Reader
-
UInt32Reader
public static final JsonReader<java.lang.Long> UInt32Reader
-
Float64Reader
public static final JsonReader<java.lang.Double> Float64Reader
-
Float32Reader
public static final JsonReader<java.lang.Float> Float32Reader
-
StringReader
public static final JsonReader<java.lang.String> StringReader
-
BinaryReader
public static final JsonReader<byte[]> BinaryReader
-
BooleanReader
public static final JsonReader<java.lang.Boolean> BooleanReader
-
VoidReader
public static final JsonReader<java.lang.Object> VoidReader
-
-
Method Detail
-
read
public abstract T read(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readFromTags
public T readFromTags(java.lang.String[] tags, com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readFields
public T readFields(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
validate
public void validate(T value)
-
readField
public final T readField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, java.lang.Object v) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readOptional
public final T readOptional(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readTags
public static java.lang.String[] readTags(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
Helper to read and parse the optional ".tag" field. If one is found, positions the parser at the next field (or the closing brace); otherwise leaves the parser position unchanged. Returns null if there isn't a ".tag" field; otherwise an array of strings (the tags). Initially the parser must be positioned right after the opening brace.- Throws:
java.io.IOException
JsonReadException
-
nextToken
public static com.fasterxml.jackson.core.JsonToken nextToken(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
A wrapper around 'JsonParser.nextToken' that throws our own betterJsonReadException
instead of Jackson'sJsonParseException
.JsonParseException is bad for two reasons. First, it extends IOException, which makes it easy to miss. Second, there's no way to get the original error message, which makes it hard to chain logical location information (see
JsonReadException.addFieldContext(java.lang.String)
andJsonReadException.addArrayContext(int)
).- Throws:
java.io.IOException
JsonReadException
-
expectObjectStart
public static com.fasterxml.jackson.core.JsonLocation expectObjectStart(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
expectObjectEnd
public static void expectObjectEnd(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
expectArrayStart
public static com.fasterxml.jackson.core.JsonLocation expectArrayStart(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
expectArrayEnd
public static com.fasterxml.jackson.core.JsonLocation expectArrayEnd(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
isArrayEnd
public static boolean isArrayEnd(com.fasterxml.jackson.core.JsonParser parser)
-
isArrayStart
public static boolean isArrayStart(com.fasterxml.jackson.core.JsonParser parser)
-
skipValue
public static void skipValue(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readUnsignedLong
public static long readUnsignedLong(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readUnsignedLongField
public static long readUnsignedLongField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, long v) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readBoolean
public static boolean readBoolean(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readDouble
public static double readDouble(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readEnum
public static <T> T readEnum(com.fasterxml.jackson.core.JsonParser parser, java.util.HashMap<java.lang.String,T> values, T catch_all) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readFully
public T readFully(java.io.InputStream utf8Body) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
readFully
public T readFully(java.lang.String body) throws JsonReadException
- Throws:
JsonReadException
-
readFully
public T readFully(byte[] utf8Body) throws JsonReadException
- Throws:
JsonReadException
-
readFromFile
public T readFromFile(java.lang.String filePath) throws JsonReader.FileLoadException
- Throws:
JsonReader.FileLoadException
-
readFromFile
public T readFromFile(java.io.File file) throws JsonReader.FileLoadException
- Throws:
JsonReader.FileLoadException
-
readFully
public T readFully(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
- Throws:
java.io.IOException
JsonReadException
-
-