Examples of EJValue


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

  }

  @Override
  public Long doNotNullDemarshall(EJValue o, MarshallingSession ctx) {
    if (o.isObject() != null) {
      EJValue numValue = o.isObject().get(SerializationParts.NUMERIC_VALUE);
      return Long.parseLong(numValue.isString().stringValue());
    }
    else {
      throw new MarshallingException("cannot demarshall as java.lang.Long: expected qualified value but got: " + o);
    }
  }
View Full Code Here

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

  protected Map doDermashall(Map impl, EJValue o, MarshallingSession ctx) {
    EJObject jsonObject = o.isObject();

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

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

    EJObject jsonObject = o.isObject();

    Object demarshalledKey, demarshalledValue;
    for (String key : jsonObject.keySet()) {
      if (key.startsWith(SerializationParts.EMBEDDED_JSON)) {
        EJValue val = ParserFactory.get().parse(key.substring(SerializationParts.EMBEDDED_JSON.length()));
        demarshalledKey = ctx.getMarshallerInstance(ctx.determineTypeFor(null, val)).demarshall(val, ctx);
      }
      else {
        demarshalledKey = key;
      }

      EJValue v = jsonObject.get(key);
      if (!v.isNull()) {
       demarshalledValue = ctx.getMarshallerInstance(ctx.determineTypeFor(null, v)).demarshall(v, ctx);
      }
      else {
        demarshalledValue = null;
      }
View Full Code Here

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

    EJObject jsonObject = o.isObject();

    Object demarshalledKey, demarshalledValue;
    for (String key : jsonObject.keySet()) {
      if (key.startsWith(SerializationParts.EMBEDDED_JSON)) {
        EJValue val = ParserFactory.get().parse(key.substring(SerializationParts.EMBEDDED_JSON.length()));
        demarshalledKey = ctx.getMarshallerInstance(ctx.determineTypeFor(null, val)).demarshall(val, ctx);
      }
      else {
        demarshalledKey = key;
      }

      EJValue v = jsonObject.get(key);
      if (!v.isNull()) {
       demarshalledValue = ctx.getMarshallerInstance(ctx.determineTypeFor(null, v)).demarshall(v, ctx);
      }
      else {
        demarshalledValue = null;
      }
View Full Code Here

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

            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

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

  public static <T> T fromJSON(final String json, final Class<T> type, final Class<?> assumedElementType) {
    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());
View Full Code Here

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

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

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

    return msg;
  }


  public static List<Message> createCommandMessage(QueueSession session, HttpServletRequest request) throws IOException {
    EJValue value = JSONStreamDecoder.decode(request.getInputStream());
    if (value.isObject() != null) {
      return Collections.singletonList(from(getParts(value), session, request));
    }
    else if (value.isArray() != null) {
      EJArray arr = value.isArray();
      List<Message> messages = new ArrayList<Message>(arr.size());
      for (int i = 0; i < arr.size(); i++) {
        messages.add(from(getParts(arr.get(i)), session, request));
      }
      return messages;
    }
    else if (value.isNull()) {
      return Collections.<Message>emptyList();
    }
    else {
      throw new RuntimeException("bad payload");
    }
View Full Code Here

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

    }
  }


  public static List<Message> createCommandMessage(QueueSession session, InputStream inputStream) throws IOException {
    EJValue value = JSONStreamDecoder.decode(inputStream);
    if (value.isObject() != null) {
      return Collections.singletonList(from(getParts(value), session, null));
    }
    else if (value.isArray() != null) {
      EJArray arr = value.isArray();
      List<Message> messages = new ArrayList<Message>(arr.size());
      for (int i = 0; i < arr.size(); i++) {
        messages.add(from(getParts(arr.get(i)), session, null));
      }
      return messages;
View Full Code Here

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

    if (!(frame instanceof TextWebSocketFrame)) {
      throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
          .getName()));
    }

    @SuppressWarnings("unchecked") final EJValue val = JSONDecoder.decode(((TextWebSocketFrame) frame).text());

    final QueueSession session;

    // this is not an active channel.
    if (!activeChannels.containsKey(ctx.channel())) {
      if (val == null) {
        sendMessage(ctx, getFailedNegotiation("illegal handshake"));
        return;
      }

      final EJObject ejObject = val.isObject();

      if (ejObject == null) {
        return;
      }

      final EJValue ejValue = ejObject.get(MessageParts.CommandType.name());

      if (ejValue.isNull()) {
        sendMessage(ctx, getFailedNegotiation("illegal handshake"));
      }

      final String commandType = ejValue.isString().stringValue();

      // this client apparently wants to connect.
      if (BusCommand.Associate.name().equals(commandType)) {
        final String sessionKey = ejObject.get(MessageParts.ConnectionSessionKey.name()).isString().stringValue();
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.