com.google.protobuf.gwt.client
Class GWTJsonStream

java.lang.Object
  extended by com.google.protobuf.gwt.shared.AbstractJsonStream
      extended by com.google.protobuf.gwt.client.GWTJsonStream
All Implemented Interfaces:
JsonStream
Direct Known Subclasses:
CompactGWTJsonStream, VerboseGWTJsonStream

public abstract class GWTJsonStream
extends AbstractJsonStream

Simple class that implements useful utility methods on top of the GWT JSON implementation.

Author:
vkulikov@alum.mit.edu Vitaliy Kulikov

Field Summary
protected  com.google.gwt.json.client.JSONObject json
           
 
Fields inherited from class com.google.protobuf.gwt.shared.AbstractJsonStream
FIELD_LABEL_KEY, FIELD_VALUE_KEY
 
Constructor Summary
protected GWTJsonStream(com.google.gwt.json.client.JSONObject json)
           
 
Method Summary
 boolean equals(Object object)
           
protected  com.google.gwt.json.client.JSONObject getJSONObject()
           
 int hashCode()
           
protected  String jsonNonPrimitiveToPrettyString(com.google.gwt.json.client.JSONValue jsonValue, int indentLevel)
           
static com.google.gwt.json.client.JSONArray jsonValueToArray(com.google.gwt.json.client.JSONValue jsonValue)
           
static Boolean jsonValueToBoolean(com.google.gwt.json.client.JSONValue jsonValue)
           
static Double jsonValueToDouble(com.google.gwt.json.client.JSONValue jsonValue)
           
static Float jsonValueToFloat(com.google.gwt.json.client.JSONValue jsonValue)
           
static Integer jsonValueToInteger(com.google.gwt.json.client.JSONValue jsonValue)
           
static Long jsonValueToLong(com.google.gwt.json.client.JSONValue jsonValue)
           
static com.google.gwt.json.client.JSONObject jsonValueToObject(com.google.gwt.json.client.JSONValue jsonValue)
           
static String jsonValueToString(com.google.gwt.json.client.JSONValue jsonValue)
           
protected abstract  GWTJsonStream newStream(com.google.gwt.json.client.JSONObject jsonObject)
           
static com.google.gwt.json.client.JSONArray parseJSONArray(String jsonText)
           
static com.google.gwt.json.client.JSONObject parseJSONObject(String jsonText)
           
protected  Boolean readBoolean(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<Boolean> readBooleanRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  Double readDouble(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<Double> readDoubleRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  Float readFloat(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<Float> readFloatRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  Integer readInteger(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<Integer> readIntegerRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  Long readLong(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<Long> readLongRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
 JsonStream readStream(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
 List<JsonStream> readStreamRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  String readString(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
protected  List<String> readStringRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldNumber)
           
 String toJsonString()
           
 String toJsonString(boolean pretty)
           
 String toString()
           
protected  com.google.gwt.json.client.JSONObject writeBoolean(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, boolean fieldBoolean)
           
protected  com.google.gwt.json.client.JSONObject writeBooleanRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<Boolean> fieldBooleanRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeDouble(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, double fieldDouble)
           
protected  com.google.gwt.json.client.JSONObject writeDoubleRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<Double> fieldDoubleRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeFloat(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, float fieldFloat)
           
protected  com.google.gwt.json.client.JSONObject writeFloatRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<Float> fieldFloatRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeInteger(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, int fieldInteger)
           
protected  com.google.gwt.json.client.JSONObject writeIntegerRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<Integer> fieldIntegerRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeLong(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, long fieldLong)
           
protected  com.google.gwt.json.client.JSONObject writeLongRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<Long> fieldLongRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeStream(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, JsonStream fieldStream)
           
protected  com.google.gwt.json.client.JSONObject writeStreamRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<JsonStream> fieldStreamRepeated)
           
protected  com.google.gwt.json.client.JSONObject writeString(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, String fieldString)
           
protected  com.google.gwt.json.client.JSONObject writeStringRepeated(com.google.gwt.json.client.JSONObject jsonObject, String fieldLabel, Collection<String> fieldStringRepeated)
           
 
Methods inherited from class com.google.protobuf.gwt.shared.AbstractJsonStream
getFieldLabelKey, getFieldValueKey, getKeyForFieldNumber, writeMessage, writeMessageRepeated
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
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
 

Field Detail

json

protected final com.google.gwt.json.client.JSONObject json
Constructor Detail

GWTJsonStream

protected GWTJsonStream(com.google.gwt.json.client.JSONObject json)
Method Detail

getJSONObject

protected com.google.gwt.json.client.JSONObject getJSONObject()

newStream

protected abstract GWTJsonStream newStream(com.google.gwt.json.client.JSONObject jsonObject)

parseJSONObject

public static com.google.gwt.json.client.JSONObject parseJSONObject(String jsonText)

parseJSONArray

public static com.google.gwt.json.client.JSONArray parseJSONArray(String jsonText)

jsonValueToObject

public static com.google.gwt.json.client.JSONObject jsonValueToObject(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToArray

public static com.google.gwt.json.client.JSONArray jsonValueToArray(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToBoolean

public static Boolean jsonValueToBoolean(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToFloat

public static Float jsonValueToFloat(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToDouble

public static Double jsonValueToDouble(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToLong

public static Long jsonValueToLong(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToInteger

public static Integer jsonValueToInteger(com.google.gwt.json.client.JSONValue jsonValue)

jsonValueToString

public static String jsonValueToString(com.google.gwt.json.client.JSONValue jsonValue)

readInteger

protected Integer readInteger(com.google.gwt.json.client.JSONObject jsonObject,
                              String fieldLabel,
                              int fieldNumber)
                       throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readIntegerRepeated

protected List<Integer> readIntegerRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                            String fieldLabel,
                                            int fieldNumber)
                                     throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeInteger

protected com.google.gwt.json.client.JSONObject writeInteger(com.google.gwt.json.client.JSONObject jsonObject,
                                                             String fieldLabel,
                                                             int fieldInteger)

writeIntegerRepeated

protected com.google.gwt.json.client.JSONObject writeIntegerRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                     String fieldLabel,
                                                                     Collection<Integer> fieldIntegerRepeated)

readFloat

protected Float readFloat(com.google.gwt.json.client.JSONObject jsonObject,
                          String fieldLabel,
                          int fieldNumber)
                   throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readFloatRepeated

protected List<Float> readFloatRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                        String fieldLabel,
                                        int fieldNumber)
                                 throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeFloat

protected com.google.gwt.json.client.JSONObject writeFloat(com.google.gwt.json.client.JSONObject jsonObject,
                                                           String fieldLabel,
                                                           float fieldFloat)

writeFloatRepeated

protected com.google.gwt.json.client.JSONObject writeFloatRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                   String fieldLabel,
                                                                   Collection<Float> fieldFloatRepeated)

readDouble

protected Double readDouble(com.google.gwt.json.client.JSONObject jsonObject,
                            String fieldLabel,
                            int fieldNumber)
                     throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readDoubleRepeated

protected List<Double> readDoubleRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                          String fieldLabel,
                                          int fieldNumber)
                                   throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeDouble

protected com.google.gwt.json.client.JSONObject writeDouble(com.google.gwt.json.client.JSONObject jsonObject,
                                                            String fieldLabel,
                                                            double fieldDouble)

writeDoubleRepeated

protected com.google.gwt.json.client.JSONObject writeDoubleRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                    String fieldLabel,
                                                                    Collection<Double> fieldDoubleRepeated)

readLong

protected Long readLong(com.google.gwt.json.client.JSONObject jsonObject,
                        String fieldLabel,
                        int fieldNumber)
                 throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readLongRepeated

protected List<Long> readLongRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                      String fieldLabel,
                                      int fieldNumber)
                               throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeLong

protected com.google.gwt.json.client.JSONObject writeLong(com.google.gwt.json.client.JSONObject jsonObject,
                                                          String fieldLabel,
                                                          long fieldLong)

writeLongRepeated

protected com.google.gwt.json.client.JSONObject writeLongRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                  String fieldLabel,
                                                                  Collection<Long> fieldLongRepeated)

readBoolean

protected Boolean readBoolean(com.google.gwt.json.client.JSONObject jsonObject,
                              String fieldLabel,
                              int fieldNumber)
                       throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readBooleanRepeated

protected List<Boolean> readBooleanRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                            String fieldLabel,
                                            int fieldNumber)
                                     throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeBoolean

protected com.google.gwt.json.client.JSONObject writeBoolean(com.google.gwt.json.client.JSONObject jsonObject,
                                                             String fieldLabel,
                                                             boolean fieldBoolean)

writeBooleanRepeated

protected com.google.gwt.json.client.JSONObject writeBooleanRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                     String fieldLabel,
                                                                     Collection<Boolean> fieldBooleanRepeated)

readString

protected String readString(com.google.gwt.json.client.JSONObject jsonObject,
                            String fieldLabel,
                            int fieldNumber)
                     throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readStringRepeated

protected List<String> readStringRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                          String fieldLabel,
                                          int fieldNumber)
                                   throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeString

protected com.google.gwt.json.client.JSONObject writeString(com.google.gwt.json.client.JSONObject jsonObject,
                                                            String fieldLabel,
                                                            String fieldString)

writeStringRepeated

protected com.google.gwt.json.client.JSONObject writeStringRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                    String fieldLabel,
                                                                    Collection<String> fieldStringRepeated)

readStream

public JsonStream readStream(com.google.gwt.json.client.JSONObject jsonObject,
                             String fieldLabel,
                             int fieldNumber)
                      throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

readStreamRepeated

public List<JsonStream> readStreamRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                           String fieldLabel,
                                           int fieldNumber)
                                    throws InvalidProtocolBufferException
Throws:
InvalidProtocolBufferException

writeStream

protected com.google.gwt.json.client.JSONObject writeStream(com.google.gwt.json.client.JSONObject jsonObject,
                                                            String fieldLabel,
                                                            JsonStream fieldStream)
                                                     throws IOException
Throws:
IOException

writeStreamRepeated

protected com.google.gwt.json.client.JSONObject writeStreamRepeated(com.google.gwt.json.client.JSONObject jsonObject,
                                                                    String fieldLabel,
                                                                    Collection<JsonStream> fieldStreamRepeated)
                                                             throws IOException
Throws:
IOException

toJsonString

public String toJsonString()

toJsonString

public String toJsonString(boolean pretty)

jsonNonPrimitiveToPrettyString

protected String jsonNonPrimitiveToPrettyString(com.google.gwt.json.client.JSONValue jsonValue,
                                                int indentLevel)

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.