Package com.goodow.realtime.json

Examples of com.goodow.realtime.json.JsonArray.push()


  @Override public JsonArray asArray() {
    final JsonArray objects = Json.createArray();
    snapshot.forEach(new ListIterator<JsonArray>() {
      @Override
      public void call(int index, JsonArray value) {
        objects.push(get(index));
      }
    });
    return objects;
  }
View Full Code Here


    snapshot.forEach(new ListIterator<JsonArray>() {
      @Override
      public void call(int index, JsonArray value) {
        Object val = get(index);
        if (val == null) {
          json.push(null);
        } else if (val instanceof CollaborativeObjectImpl) {
          json.push(((CollaborativeObject) val).toJson());
        } else {
          json.push(snapshot.getArray(index).get(1));
        }
View Full Code Here

      public void call(int index, JsonArray value) {
        Object val = get(index);
        if (val == null) {
          json.push(null);
        } else if (val instanceof CollaborativeObjectImpl) {
          json.push(((CollaborativeObject) val).toJson());
        } else {
          json.push(snapshot.getArray(index).get(1));
        }
      }
    });
View Full Code Here

        if (val == null) {
          json.push(null);
        } else if (val instanceof CollaborativeObjectImpl) {
          json.push(((CollaborativeObject) val).toJson());
        } else {
          json.push(snapshot.getArray(index).get(1));
        }
      }
    });
    return json;
  }
View Full Code Here

    assert index <= length();
    final JsonArray objects = Json.createArray();
    values.forEach(new ListIterator<JsonArray>() {
      @Override
      public void call(int idx, JsonArray value) {
        objects.push(JsonSerializer.deserializeObject(value, model.objects));
        snapshot.insert(index + idx, value);
        model.addOrRemoveParent(value, id, true);
        model.bytesUsed += (value == null ? "null" : value.toJsonString()).length();
      }
    });
View Full Code Here

  private void removeAndFireEvent(int index, int length, String sessionId, String userId) {
    assert index + length <= length();
    JsonArray objects = Json.createArray();
    for (int i = 0; i < length; i++) {
      objects.push(get(index));
      JsonArray value = snapshot.getArray(index);
      snapshot.remove(index);
      model.addOrRemoveParent(value, id, false);
      model.bytesUsed -= (value == null ? "null" : value.toJsonString()).length();
    }
View Full Code Here

    final JsonArray newObjects = Json.createArray();
    values.forEach(new ListIterator<JsonArray>() {
      @Override
      public void call(int idx, JsonArray newValue) {
        oldObjects.push(get(index + idx));
        newObjects.push(JsonSerializer.deserializeObject(newValue, model.objects));
        JsonArray oldValue = snapshot.getArray(index + idx);
        snapshot.remove(index + idx);
        snapshot.insert(index + idx++, newValue);
        model.addOrRemoveParent(oldValue, id, false);
        model.addOrRemoveParent(newValue, id, true);
View Full Code Here

  }

  private JsonArray subValues(int startIndex, int length) {
    JsonArray array = Json.createArray();
    for (int i = startIndex; i < startIndex + length; i++) {
      array.push(snapshot.getArray(i));
    }
    return array;
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.