Ejemplo n.º 1
0
 protected JSONObject writeStream(JSONObject jsonObject, String fieldLabel, JsonStream fieldStream)
     throws IOException {
   if (jsonObject != null && fieldLabel != null) {
     if (fieldStream instanceof GWTJsonStream) {
       GWTJsonStream fieldGWTJsonStream = (GWTJsonStream) fieldStream;
       jsonObject.put(fieldLabel, fieldGWTJsonStream.getJSONObject());
     } else {
       throw new IOException("Failed to write stream field " + fieldLabel);
     }
   }
   return jsonObject;
 }
Ejemplo n.º 2
0
 protected JSONObject writeStreamRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<JsonStream> fieldStreamRepeated)
     throws IOException {
   if (jsonObject != null
       && fieldLabel != null
       && fieldStreamRepeated != null
       && !fieldStreamRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (JsonStream fieldStream : fieldStreamRepeated) {
       if (fieldStream instanceof GWTJsonStream) {
         GWTJsonStream fieldGWTJsonStream = (GWTJsonStream) fieldStream;
         fieldJSONArray.set(i++, fieldGWTJsonStream.getJSONObject());
       } else {
         throw new IOException("Failed to write repeated stream field " + fieldLabel);
       }
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }