Package com.google.gwt.json.client

Examples of com.google.gwt.json.client.JSONValue


    entity = newInstance();
    try {
      eem.putPartiallyConstructedEntity(key, entity);
      for (Attribute<? super X, ?> a : getAttributes()) {
        ErraiAttribute<? super X, ?> attr = (ErraiAttribute<? super X, ?>) a;
        JSONValue attrJsonValue = jsonValue.isObject().get(attr.getName());

        switch (attr.getPersistentAttributeType()) {
        case ELEMENT_COLLECTION:
        case EMBEDDED:
        case BASIC:
          parseInlineJson(entity, attr, attrJsonValue, eem);
          break;

        case MANY_TO_MANY:
        case MANY_TO_ONE:
        case ONE_TO_MANY:
        case ONE_TO_ONE:
          if (attr instanceof ErraiSingularAttribute) {
            parseSingularJsonReference(entity, (ErraiSingularAttribute<? super X, ?>) attr, attrJsonValue, eem);
          }
          else if (attr instanceof ErraiPluralAttribute) {
            parsePluralJsonReference(entity, (ErraiPluralAttribute<? super X, ?, ?>) attr, attrJsonValue.isArray(), eem);
          }
          else {
            throw new PersistenceException("Unknown attribute type " + attr);
          }
        }
View Full Code Here


      case MANY_TO_MANY:
      case MANY_TO_ONE:
      case ONE_TO_MANY:
      case ONE_TO_ONE:
        JSONValue attributeValue;
        if (attr instanceof ErraiSingularAttribute) {
          attributeValue = makeJsonReference(targetEntity, (ErraiSingularAttribute<? super X, ?>) attr, eem);
        }
        else if (attr instanceof ErraiPluralAttribute) {
          attributeValue = makeJsonReference(targetEntity, (ErraiPluralAttribute<? super X, ?, ?>) attr, eem);
View Full Code Here

    if (attrEntityType == null) {
      throw new IllegalArgumentException("Can't make a reference to non-entity-typed attribute " + attr);
    }

    Object idToReference = attrEntityType.getId(Object.class).get(entityToReference);
    JSONValue ref;
    if (idToReference == null) {
      ref = JSONNull.getInstance();
    }
    else {
      // XXX attrEntityType is incorrect entityToReference is a subtype of attr.getJavaType()
View Full Code Here

    JSONArray array = new JSONArray();
    int index = 0;
    for (E element : (Iterable<E>) attrValue) {
      Object idToReference = attrEntityType.getId(Object.class).get(element);
      JSONValue ref;
      if (idToReference == null) {
        ref = JSONNull.getInstance();
      }
      else {
        // XXX attrEntityType is incorrect for collection elements that are subtypes of the attrEntityType
View Full Code Here

    attr.set(targetEntity, (C) collection);
  }

  private Key<X, ?> keyFromJson(JSONValue json) {
    JSONValue keyJson = json.isObject().get(id.getName());
    Object idValue = JsonUtil.basicValueFromJson(keyJson, id.getJavaType());
    return new Key<X, Object>(this, idValue);
  }
View Full Code Here

  @Override
  public <X> void put(Key<X,?> key, X value) {
    ErraiEntityType<X> entityType = key.getEntityType();
    String keyJson = key.toJson();
    JSONValue valueJson = entityType.toJson(em, value);
    System.out.println(">>>put '" + keyJson + "'");
    putImpl(keyJson, valueJson.toString());
  }
View Full Code Here

  @Override
  public <X> boolean isModified(Key<X, ?> key, X value) {
    ErraiEntityType<X> entityType = key.getEntityType();
    String keyJson = key.toJson();
    JSONValue newValueJson = entityType.toJson(em, value);
    JSONValue oldValueJson = JSONParser.parseStrict(getImpl(keyJson));
    boolean modified = !JsonUtil.equals(newValueJson, oldValueJson);
    if (modified) {
      System.out.println("Detected modified entity " + key);
      System.out.println("   Old: " + oldValueJson);
      System.out.println("   New: " + newValueJson);
View Full Code Here

      JSONArray array = new JSONArray(items);
      for (int i = 0; i < array.size(); i++) {
        Truck truck = trucks.get(index + i);

        Truck checkTruck = null;
        JSONValue value = array.get(i);
        JSONObject item = null;
        if (value != null) {
          item = value.isObject();
        }
        if (item != null) {
          checkTruck = new Truck(item);
        }
       
View Full Code Here

    public void fromJSON(JSONObject object) {
      if (object == null) {
        return;
      }
     
      JSONValue uuid = object.get("_uuid");
      if (uuid != null) {
        if (uuid.isString() != null) {
          this._uuid = uuid.isString().stringValue();
        }
      }

      JSONValue updateSeq = object.get("_updateSeq");
      if (updateSeq != null) {
        if (updateSeq.isNumber() != null) {
          this._updateSeq = (int) updateSeq.isNumber().doubleValue();
        }
      }

      JSONValue name = object.get("name");
      if (name != null) {
        if (name.isString() != null) {
          this.name = name.isString().stringValue();
        }
      }

      JSONValue capacity = object.get("capacity");
      if (capacity != null) {
        if (capacity.isNumber() != null) {
          this.capacity = (int) (capacity.isNumber().doubleValue());
        }
      }     

      JSONValue store = object.get("store");
      if (store != null) {
        if (store.isString() != null) {
          this.store = store.isString().stringValue();
        }
      }
    }
View Full Code Here

      JSONArray array = new JSONArray(items);
      for (int i = 0; i < array.size(); i++) {
        Truck truck = trucks.get(index + i);

        Truck checkTruck = null;
        JSONValue value = array.get(i);
        JSONObject item = null;
        if (value != null) {
          item = value.isObject();
        }
        if (item != null) {
          checkTruck = new Truck(item);
        }
       
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONValue

Copyright © 2018 www.massapicom. 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.