Exemplo n.º 1
0
 public List<JsonStream> readStreamRepeated(
     JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   List<JsonStream> fieldStreamRepeated = null;
   if (jsonObject != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       JSONArray fieldJSONArray = jsonValueToArray(fieldValue);
       if (fieldJSONArray != null) {
         fieldStreamRepeated = new ArrayList<JsonStream>();
         for (int i = 0; i < fieldJSONArray.size(); ++i) {
           JsonStream fieldStream = null;
           JSONObject fieldJSONObject = jsonValueToObject(fieldJSONArray.get(i));
           if (fieldJSONObject != null) {
             fieldStream = this.newStream(fieldJSONObject);
           }
           if (fieldStream != null) {
             fieldStreamRepeated.add(fieldStream);
           } else {
             throw InvalidProtocolBufferException.failedToReadObjectRepeated(fieldLabel);
           }
         }
       } else {
         throw InvalidProtocolBufferException.failedToReadObjectRepeated(fieldLabel);
       }
     }
   }
   return fieldStreamRepeated;
 }
Exemplo n.º 2
0
 protected List<String> readStringRepeated(
     JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   List<String> fieldStringRepeated = null;
   if (jsonObject != null && fieldLabel != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       JSONArray fieldJSONArray = jsonValueToArray(fieldValue);
       if (fieldJSONArray != null) {
         fieldStringRepeated = new ArrayList<String>();
         for (int i = 0; i < fieldJSONArray.size(); ++i) {
           String fieldString = jsonValueToString(fieldJSONArray.get(i));
           if (fieldString != null) {
             fieldStringRepeated.add(fieldString);
           } else {
             throw InvalidProtocolBufferException.failedToReadStringRepeated(fieldLabel);
           }
         }
       } else {
         throw InvalidProtocolBufferException.failedToReadStringRepeated(fieldLabel);
       }
     }
   }
   return fieldStringRepeated;
 }
Exemplo n.º 3
0
 protected String readString(JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   String fieldString = null;
   if (jsonObject != null && fieldLabel != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       fieldString = jsonValueToString(fieldValue);
       if (fieldString == null) {
         throw InvalidProtocolBufferException.failedToReadString(fieldLabel);
       }
     }
   }
   return fieldString;
 }
Exemplo n.º 4
0
 protected Boolean readBoolean(JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   Boolean fieldBoolean = null;
   if (jsonObject != null && fieldLabel != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       fieldBoolean = jsonValueToBoolean(fieldValue);
       if (fieldBoolean == null) {
         throw InvalidProtocolBufferException.failedToReadBoolean(fieldLabel);
       }
     }
   }
   return fieldBoolean;
 }
Exemplo n.º 5
0
 protected Integer readInteger(JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   Integer fieldInteger = null;
   if (jsonObject != null && fieldLabel != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       fieldInteger = jsonValueToInteger(fieldValue);
       if (fieldInteger == null) {
         throw InvalidProtocolBufferException.failedToReadInteger(fieldLabel);
       }
     }
   }
   return fieldInteger;
 }
Exemplo n.º 6
0
 public JsonStream readStream(JSONObject jsonObject, String fieldLabel, int fieldNumber)
     throws InvalidProtocolBufferException {
   JsonStream fieldStream = null;
   if (jsonObject != null && fieldLabel != null) {
     JSONValue fieldValue = jsonObject.get(fieldLabel);
     if (fieldValue != null) {
       JSONObject fieldJSONObject = jsonValueToObject(fieldValue);
       if (fieldJSONObject != null) {
         fieldStream = this.newStream(fieldJSONObject);
       }
       if (fieldStream == null) {
         throw InvalidProtocolBufferException.failedToReadObject(fieldLabel);
       }
     }
   }
   return fieldStream;
 }