com.google.protobuf.gwt.server
Class GsonJsonStream
java.lang.Object
com.google.protobuf.gwt.shared.AbstractJsonStream
com.google.protobuf.gwt.server.GsonJsonStream
- All Implemented Interfaces:
- JsonStream
- Direct Known Subclasses:
- CompactGsonJsonStream, VerboseGsonJsonStream
public abstract class GsonJsonStream
- extends AbstractJsonStream
Simple class that implements useful utility methods on top of the Gson JSON
implementation.
- Author:
- vkulikov@alum.mit.edu Vitaliy Kulikov
Field Summary |
protected com.google.gson.JsonObject |
json
|
Constructor Summary |
protected |
GsonJsonStream(com.google.gson.JsonObject json)
|
Method Summary |
boolean |
equals(Object object)
|
protected com.google.gson.JsonObject |
getJsonObject()
|
int |
hashCode()
|
static com.google.gson.JsonArray |
jsonElementToArray(com.google.gson.JsonElement jsonElement)
|
static Boolean |
jsonElementToBoolean(com.google.gson.JsonElement jsonElement)
|
static Double |
jsonElementToDouble(com.google.gson.JsonElement jsonElement)
|
static Float |
jsonElementToFloat(com.google.gson.JsonElement jsonElement)
|
static Integer |
jsonElementToInteger(com.google.gson.JsonElement json)
|
static Long |
jsonElementToLong(com.google.gson.JsonElement jsonElement)
|
static com.google.gson.JsonObject |
jsonElementToObject(com.google.gson.JsonElement jsonElement)
|
static String |
jsonElementToString(com.google.gson.JsonElement json)
|
protected abstract GsonJsonStream |
newStream(com.google.gson.JsonObject jsonObject)
|
static com.google.gson.JsonArray |
parseJsonArray(String jsonText)
|
static com.google.gson.JsonObject |
parseJsonObject(String jsonText)
|
protected Boolean |
readBoolean(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<Boolean> |
readBooleanRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected Double |
readDouble(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<Double> |
readDoubleRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected Float |
readFloat(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<Float> |
readFloatRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected Integer |
readInteger(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<Integer> |
readIntegerRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected Long |
readLong(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<Long> |
readLongRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
JsonStream |
readStream(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
List<JsonStream> |
readStreamRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected String |
readString(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
protected List<String> |
readStringRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
|
String |
toJsonString()
|
String |
toJsonString(boolean pretty)
|
String |
toString()
|
protected com.google.gson.JsonObject |
writeBoolean(com.google.gson.JsonObject jsonObject,
String fieldLabel,
boolean fieldBoolean)
|
protected com.google.gson.JsonObject |
writeBooleanRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Boolean> fieldBooleanRepeated)
|
protected com.google.gson.JsonObject |
writeDouble(com.google.gson.JsonObject jsonObject,
String fieldLabel,
double fieldDouble)
|
protected com.google.gson.JsonObject |
writeDoubleRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Double> fieldDoubleRepeated)
|
protected com.google.gson.JsonObject |
writeFloat(com.google.gson.JsonObject jsonObject,
String fieldLabel,
float fieldFloat)
|
protected com.google.gson.JsonObject |
writeFloatRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Float> fieldFloatRepeated)
|
protected com.google.gson.JsonObject |
writeInteger(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldInteger)
|
protected com.google.gson.JsonObject |
writeIntegerRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Integer> fieldIntegerRepeated)
|
protected com.google.gson.JsonObject |
writeLong(com.google.gson.JsonObject jsonObject,
String fieldLabel,
long fieldLong)
|
protected com.google.gson.JsonObject |
writeLongRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Long> fieldLongRepeated)
|
protected com.google.gson.JsonObject |
writeStream(com.google.gson.JsonObject jsonObject,
String fieldLabel,
JsonStream fieldStream)
|
protected com.google.gson.JsonObject |
writeStreamRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<JsonStream> fieldStreamRepeated)
|
protected com.google.gson.JsonObject |
writeString(com.google.gson.JsonObject jsonObject,
String fieldLabel,
String fieldString)
|
protected com.google.gson.JsonObject |
writeStringRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<String> fieldStringRepeated)
|
Methods inherited from interface com.google.protobuf.gwt.shared.JsonStream |
newStream, readBoolean, readBooleanRepeated, readDouble, readDoubleRepeated, readFloat, readFloatRepeated, readInteger, readIntegerRepeated, readLong, readLongRepeated, readStream, readStreamRepeated, readString, readStringRepeated, writeBoolean, writeBooleanRepeated, writeDouble, writeDoubleRepeated, writeFloat, writeFloatRepeated, writeInteger, writeIntegerRepeated, writeLong, writeLongRepeated, writeStream, writeStreamRepeated, writeString, writeStringRepeated |
json
protected final com.google.gson.JsonObject json
GsonJsonStream
protected GsonJsonStream(com.google.gson.JsonObject json)
getJsonObject
protected com.google.gson.JsonObject getJsonObject()
newStream
protected abstract GsonJsonStream newStream(com.google.gson.JsonObject jsonObject)
parseJsonObject
public static com.google.gson.JsonObject parseJsonObject(String jsonText)
parseJsonArray
public static com.google.gson.JsonArray parseJsonArray(String jsonText)
jsonElementToInteger
public static Integer jsonElementToInteger(com.google.gson.JsonElement json)
jsonElementToBoolean
public static Boolean jsonElementToBoolean(com.google.gson.JsonElement jsonElement)
jsonElementToFloat
public static Float jsonElementToFloat(com.google.gson.JsonElement jsonElement)
jsonElementToDouble
public static Double jsonElementToDouble(com.google.gson.JsonElement jsonElement)
jsonElementToLong
public static Long jsonElementToLong(com.google.gson.JsonElement jsonElement)
jsonElementToString
public static String jsonElementToString(com.google.gson.JsonElement json)
jsonElementToArray
public static com.google.gson.JsonArray jsonElementToArray(com.google.gson.JsonElement jsonElement)
jsonElementToObject
public static com.google.gson.JsonObject jsonElementToObject(com.google.gson.JsonElement jsonElement)
readInteger
protected Integer readInteger(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readIntegerRepeated
protected List<Integer> readIntegerRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeInteger
protected com.google.gson.JsonObject writeInteger(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldInteger)
writeIntegerRepeated
protected com.google.gson.JsonObject writeIntegerRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Integer> fieldIntegerRepeated)
readFloat
protected Float readFloat(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readFloatRepeated
protected List<Float> readFloatRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeFloat
protected com.google.gson.JsonObject writeFloat(com.google.gson.JsonObject jsonObject,
String fieldLabel,
float fieldFloat)
writeFloatRepeated
protected com.google.gson.JsonObject writeFloatRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Float> fieldFloatRepeated)
readDouble
protected Double readDouble(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readDoubleRepeated
protected List<Double> readDoubleRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeDouble
protected com.google.gson.JsonObject writeDouble(com.google.gson.JsonObject jsonObject,
String fieldLabel,
double fieldDouble)
writeDoubleRepeated
protected com.google.gson.JsonObject writeDoubleRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Double> fieldDoubleRepeated)
readLong
protected Long readLong(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readLongRepeated
protected List<Long> readLongRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeLong
protected com.google.gson.JsonObject writeLong(com.google.gson.JsonObject jsonObject,
String fieldLabel,
long fieldLong)
writeLongRepeated
protected com.google.gson.JsonObject writeLongRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Long> fieldLongRepeated)
readBoolean
protected Boolean readBoolean(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readBooleanRepeated
protected List<Boolean> readBooleanRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeBoolean
protected com.google.gson.JsonObject writeBoolean(com.google.gson.JsonObject jsonObject,
String fieldLabel,
boolean fieldBoolean)
writeBooleanRepeated
protected com.google.gson.JsonObject writeBooleanRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<Boolean> fieldBooleanRepeated)
readString
protected String readString(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readStringRepeated
protected List<String> readStringRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeString
protected com.google.gson.JsonObject writeString(com.google.gson.JsonObject jsonObject,
String fieldLabel,
String fieldString)
writeStringRepeated
protected com.google.gson.JsonObject writeStringRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<String> fieldStringRepeated)
readStream
public JsonStream readStream(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
readStreamRepeated
public List<JsonStream> readStreamRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
int fieldNumber)
throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
writeStream
protected com.google.gson.JsonObject writeStream(com.google.gson.JsonObject jsonObject,
String fieldLabel,
JsonStream fieldStream)
throws IOException
- Throws:
IOException
writeStreamRepeated
protected com.google.gson.JsonObject writeStreamRepeated(com.google.gson.JsonObject jsonObject,
String fieldLabel,
Collection<JsonStream> fieldStreamRepeated)
throws IOException
- Throws:
IOException
toJsonString
public String toJsonString()
toJsonString
public String toJsonString(boolean pretty)
equals
public boolean equals(Object object)
- Overrides:
equals
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2014 InMobi. All rights reserved.