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

Examples of org.jboss.errai.marshalling.client.api.MarshallingSession


    if (obj == null) {
      return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"java.lang.Object\",\""
              + SerializationParts.QUALIFIED_VALUE + "\":null}";
    }

    MarshallingSession session = MarshallingSessionProviderFactory.getEncoding();

    if (needsQualification(obj)) {
      return NumbersUtils.qualifiedNumericEncoding(obj);
    }
    else {
      return session.getMarshallerInstance(obj.getClass().getName()).marshall(obj, session);
    }
  }
View Full Code Here


  public static String toJSON(List arr) {
    return ListMarshaller.INSTANCE.marshall(arr, MarshallingSessionProviderFactory.getEncoding());
  }

  public static <T> T fromJSON(String json, Class<T> type) {
    MarshallingSession session = MarshallingSessionProviderFactory.getDecoding();
    return (T) session.getMarshallerInstance(type.getName()).demarshall(ParserFactory.get().parse(json), session);
  }
View Full Code Here

    if (obj == null) {
      return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"java.lang.Object\",\""
              + SerializationParts.QUALIFIED_VALUE + "\":null}";
    }

    final MarshallingSession session = MarshallingSessionProviderFactory.getEncoding();

    if (needsQualification(obj)) {
      return NumbersUtils.qualifiedNumericEncoding(obj);
    }
    else {
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<?> 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());
    if (marshallerInstance == null) {
        throw new RuntimeException("No marshaller for type: " + type.getName());
    }
    return (T) marshallerInstance.demarshall(parsedValue, session);
  }
View Full Code Here

   */
  @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());
    if (marshallerInstance == null) {
      throw new RuntimeException("No marshaller for type: " + type.getName());
    }
    return (T) marshallerInstance.demarshall(parsedValue, session);
  }
View Full Code Here

/**
* @author Mike Brock
*/
public abstract class ServerMarshalling extends Marshalling {
  public static <T> T fromJSON(InputStream inputStream, Class<T> type) throws IOException {
    MarshallingSession session = MarshallingSessionProviderFactory.getDecoding();
    return (T) session.getMarshallerInstance(type.getName()).demarshall(JSONStreamDecoder.decode(inputStream), session);
  }
View Full Code Here

    if (obj == null) {
      return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"java.lang.Object\",\""
              + SerializationParts.QUALIFIED_VALUE + "\":null}";
    }

    final MarshallingSession session = MarshallingSessionProviderFactory.getEncoding();
   
    obj = MarshallUtil.maybeUnwrap(obj);

    if (needsQualification(obj)) {
      return NumbersUtils.qualifiedNumericEncoding(obj);
View Full Code Here

    if (json == null || "null".equals(json)) {
      return null;
    }

    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());
    if (marshallerInstance == null) {
        throw new RuntimeException("No marshaller for type: " + type.getName());
    }

    return (T) marshallerInstance.demarshall(parsedValue, session);
View Full Code Here

   */
  @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());
    if (marshallerInstance == null) {
      throw new RuntimeException("No marshaller for type: " + type.getName());
    }
    return (T) marshallerInstance.demarshall(parsedValue, session);
  }
View Full Code Here

    if (obj == null) {
      return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"java.lang.Object\",\""
              + SerializationParts.QUALIFIED_VALUE + "\":null}";
    }

    final MarshallingSession session = MarshallingSessionProviderFactory.getEncoding();

    if (needsQualification(obj)) {
      return NumbersUtils.qualifiedNumericEncoding(obj);
    }
    else {
View Full Code Here

TOP

Related Classes of org.jboss.errai.marshalling.client.api.MarshallingSession

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.