Exemplo n.º 1
0
 @Override
 public String deserialize(Slice object, MutableInt offset) {
   offset.add(object.offset);
   String string = GPOUtils.deserializeString(object.buffer, offset);
   offset.subtract(object.offset);
   return string;
 }
  private String serializeHelper(Message result, ResultFormatter resultFormatter) throws Exception {
    DataResultSnapshot gResult = (DataResultSnapshot) result;

    JSONObject jo = new JSONObject();
    jo.put(Result.FIELD_ID, gResult.getId());
    jo.put(Result.FIELD_TYPE, gResult.getType());

    JSONArray ja = new JSONArray();

    for (GPOMutable value : gResult.getValues()) {
      JSONObject dataValue =
          GPOUtils.serializeJSONObject(
              value, ((DataQuerySnapshot) gResult.getQuery()).getFields(), resultFormatter);
      ja.put(dataValue);
    }

    jo.put(DataResultSnapshot.FIELD_DATA, ja);

    if (!gResult.isOneTime()) {
      jo.put(Result.FIELD_COUNTDOWN, gResult.getCountdown());
    }

    return jo.toString();
  }
Exemplo n.º 3
0
 @Override
 public Slice serialize(String object) {
   return new Slice(GPOUtils.serializeString(object));
 }