Package org.jboss.errai.marshalling.client.api.json

Examples of org.jboss.errai.marshalling.client.api.json.EJValue


    final EJObject jsonObject = o.isObject();

    for (final String key : jsonObject.keySet()) {
      if (MessageParts.SessionID.name().equals(key))
        continue;
      final EJValue v = jsonObject.get(key);
      if (!v.isNull()) {
        final Marshaller<Object> marshallerInstance = ctx.getMarshallerInstance(ctx.determineTypeFor(null, v));
        impl.put(key, marshallerInstance.demarshall(v, ctx));
      }
      else {
        impl.put(key, null);
View Full Code Here


      if (ctx.hasObject(objId)) {
        // noinspection unchecked
        return (T) ctx.getObject(Object.class, objId);
      }

      EJValue val = obj.get(SerializationParts.QUALIFIED_VALUE);
      if (val.isNull()) {
        val = o;
      }
      return ctx.recordObject(objId, delegate.demarshall(val, ctx));
    }
    else {
View Full Code Here

  }

  @Override
  public Date doNotNullDemarshall(final EJValue o, final MarshallingSession ctx) {
    if (o.isObject() != null) {
      EJValue qualifiedValue = o.isObject().get(SerializationParts.QUALIFIED_VALUE);
      if (!qualifiedValue.isNull() && qualifiedValue.isString() != null) {
        return new Date(Long.parseLong(qualifiedValue.isString().stringValue()));
      }
      EJValue numericValue = o.isObject().get(SerializationParts.NUMERIC_VALUE);
      if (!numericValue.isNull() && numericValue.isNumber() != null) {
        return new Date(new Double(numericValue.isNumber().doubleValue()).longValue());
      }
      if (!numericValue.isNull() && numericValue.isString() != null) {
        return new Date(Long.parseLong(numericValue.isString().stringValue()));
      }
    }

    return null;
  }
View Full Code Here

  }

  @Override
  public Timestamp doNotNullDemarshall(final EJValue o, final MarshallingSession ctx) {
    if (o.isObject() != null) {
      final EJValue qualifiedValue = o.isObject().get(SerializationParts.QUALIFIED_VALUE);
      if (!qualifiedValue.isNull() && qualifiedValue.isString() != null) {
        return new Timestamp(Long.parseLong(qualifiedValue.isString().stringValue()));
      }
      final EJValue numericValue = o.isObject().get(SerializationParts.NUMERIC_VALUE);
      if (!numericValue.isNull() && numericValue.isNumber() != null) {
        return new Timestamp(new Double(numericValue.isNumber().doubleValue()).longValue());
      }
      if (!numericValue.isNull() && numericValue.isString() != null) {
        return new Timestamp(Long.parseLong(numericValue.isString().stringValue()));
      }
    }

    return null;
  }
View Full Code Here

public class TimeMarshaller extends AbstractNullableMarshaller<Time> {

  @Override
  public Time doNotNullDemarshall(final EJValue o, final MarshallingSession ctx) {
    if (o.isObject() != null) {
      final EJValue qualifiedValue = o.isObject().get(SerializationParts.QUALIFIED_VALUE);
      if (!qualifiedValue.isNull() && qualifiedValue.isString() != null) {
        return new Time(Long.parseLong(qualifiedValue.isString().stringValue()));
      }
      final EJValue numericValue = o.isObject().get(SerializationParts.NUMERIC_VALUE);
      if (!numericValue.isNull() && numericValue.isNumber() != null) {
        return new Time(new Double(numericValue.isNumber().doubleValue()).longValue());
      }
      if (!numericValue.isNull() && numericValue.isString() != null) {
        return new Time(Long.parseLong(numericValue.isString().stringValue()));
      }
    }
   
    return null;
  }
View Full Code Here

      return null;
    }

    if (o.isObject() != null) {
      final EJObject jsObject = o.isObject();
      final EJValue ejEncType = jsObject.get(SerializationParts.ENCODED_TYPE);
      String encodedType = null;
      if (!ejEncType.isNull() && ejEncType.isString() != null) {
        encodedType = ejEncType.isString().stringValue();
      }

      if (encodedType == null) {
        if (targetType == null) {
          return MapMarshaller.INSTANCE.demarshall(o, ctx);
View Full Code Here

   *          is not a collection, or its element type is provided in the JSON message.
   * @return the root of the reconstructed object graph.
   */
  @SuppressWarnings("unchecked")
  public static <T> T fromJSON(final String json, final Class<T> type, final Class<?> assumedElementType) {
    final EJValue parsedValue = ParserFactory.get().parse(json);
    final MarshallingSession session = MarshallingSessionProviderFactory.getDecoding();
    if (assumedElementType != null) {
      session.setAssumedElementType(assumedElementType.getName());
    }
    final Marshaller<Object> marshallerInstance = session.getMarshallerInstance(type.getName());
View Full Code Here

   * @return the root of the reconstructed object graph.
   */
  @SuppressWarnings("unchecked")
  public static <T> T fromJSON(final String json, final Class<T> type, final Class<?> assumedMapKeyType,
      final Class<?> assumedMapValueType) {
    final EJValue parsedValue = ParserFactory.get().parse(json);
    final MarshallingSession session = MarshallingSessionProviderFactory.getDecoding();
    session.setAssumedMapKeyType(assumedMapKeyType.getName());
    session.setAssumedMapValueType(assumedMapValueType.getName());

    final Marshaller<Object> marshallerInstance = session.getMarshallerInstance(type.getName());
View Full Code Here

    super(context);
  }

  @Override
  public String determineTypeFor(final String formatType, final Object o) {
    final EJValue jsonValue = (EJValue) o;

    if (jsonValue.isObject() != null) {
      final EJObject jsonObject = jsonValue.isObject();
      if (jsonObject.containsKey(SerializationParts.ENCODED_TYPE)) {
        return jsonObject.get(SerializationParts.ENCODED_TYPE).isString().stringValue();
      }
      else {
        return Map.class.getName();
      }
    }
    else if (jsonValue.isString() != null) {
      return String.class.getName();
    }
    else if (jsonValue.isNumber() != null) {
      return Double.class.getName();
    }
    else if (jsonValue.isBoolean() != null) {
      return Boolean.class.getName();
    }
    else if (jsonValue.isArray() != null) {
      return List.class.getName();
    }
    else if (jsonValue.isNull()) {
      return null;
    }
    else {
      return jsonValue.getRawValue().getClass().getName();
    }
  }
View Full Code Here

            ctx.recordObject(objID, newInstance);
          }

          for (final MemberMapping mapping : definition.getWritableMemberMappings()) {
            final EJValue o1 = oMap.get(mapping.getKey());

            if (!o1.isNull()) {
              final Marshaller<Object> marshaller
                      = ctx.getMarshallerInstance(mapping.getType().getFullyQualifiedName());

              if (mapping.getBindingMember() instanceof MetaField) {
                final MetaField f = (MetaField) mapping.getBindingMember();
View Full Code Here

TOP

Related Classes of org.jboss.errai.marshalling.client.api.json.EJValue

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.