Examples of JsonValue


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

                    int size = properties.size();
                    for (int i = 0; i < size; i++) {
                        Property property = properties.get(i);
                        Object propertyValue = property.getValue(value);
                        Type propertyType = property.getType();
                        JSONValue encodedPropertyValue = encode(propertyValue,
                                propertyType, connection);
                        jsonObject
                                .put(property.getName(), encodedPropertyValue);
                    }
                    return jsonObject;
View Full Code Here

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

        JSONObject jsonMap = new JSONObject();

        for (Entry<?, ?> entry : map.entrySet()) {
            Connector connector = (Connector) entry.getKey();

            JSONValue encodedValue = encodeChildValue(entry.getValue(), type,
                    1, connection);

            jsonMap.put(connector.getConnectorId(), encodedValue);
        }
View Full Code Here

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

    private static JSONValue encodeCollection(Collection collection, Type type,
            ApplicationConnection connection) {
        JSONArray jsonArray = new JSONArray();
        int idx = 0;
        for (Object o : collection) {
            JSONValue encodedObject = encodeChildValue(o, type, 0, connection);
            jsonArray.set(idx++, encodedObject);
        }
        if (collection instanceof Set) {
            return jsonArray;
        } else if (collection instanceof List) {
View Full Code Here

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

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

      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

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

    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

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

    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

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

    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

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

  @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

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

  @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
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.