Examples of JsonInput


Examples of com.caucho.json.JsonInput

  }

  public void init(InputStream is)
  {
    _is = is;
    _in = new JsonInput(is);
  }
View Full Code Here

Examples of com.caucho.json.JsonInput

    throws IOException
  {
    if (actorStream == null)
      throw new IllegalStateException("HmtpReader.readPacket requires a valid ActorStream for callbacks");

    JsonInput in = _in;

    if (in == null)
      return false;

    String type = readString();
    String to = readString();
    String from = readString();
    String payloadType = readString();
    Class payloadClass = getPayloadClass(payloadType);

    HmtpPacketType packetType = _typeMap.get(type);

    if (packetType == null) {
      throw new IllegalStateException("'" + type + "' is an unknown packet type");
    }

    switch (packetType) {
    case MESSAGE:
      {
        Serializable value = (Serializable) in.readObject(payloadClass);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " message " + value
                    + " {to:" + to + ", from:" + from + "}");
        }

        actorStream.message(to, from, value);

        break;
      }

    case MESSAGE_ERROR:
      {
        Serializable value = (Serializable) in.readObject();
        BamError error = (BamError) in.readObject(BamError.class);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " messageError " + error + " " + value
                    + " {to:" + to + ", from:" + from + "}");
        }

        actorStream.messageError(to, from, value, error);

        break;
      }

    case QUERY:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " query " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }

        actorStream.query(id, to, from, value);

        break;
      }

    case QUERY_RESULT:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " queryResult " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }

        actorStream.queryResult(id, to, from, value);

        break;
      }

    case QUERY_ERROR:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        BamError error = (BamError) in.readObject(BamError.class);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " queryError " + error + " " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }
View Full Code Here

Examples of com.caucho.json.JsonInput

  }

  public void close()
  {
    try {
      JsonInput in = _in;
      _in = null;

      if (in != null)
        in.close();
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }

    // _client.close();
View Full Code Here

Examples of org.structr.core.JsonInput

  @Override
  public IJsonInput deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {

    IJsonInput jsonInput = null;
    JsonInput wrapper = null;
    if (json.isJsonObject()) {
      jsonInput = new JsonSingleInput();
      wrapper = deserialize(json, context);
      jsonInput.add(wrapper);
View Full Code Here

Examples of org.structr.core.JsonInput

  }
 
 
  private JsonInput deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException {

    JsonInput wrapper = new JsonInput();
    if (json.isJsonObject()) {
      JsonObject obj = json.getAsJsonObject();

      for (Entry<String, JsonElement> entry : obj.entrySet()) {

        String key       = entry.getKey();
        JsonElement elem = entry.getValue();

        // static mapping of IdProperty if present
        if ((idProperty != null) && "id".equals(key)) {

          key = idProperty.jsonName();

        }

        if (elem.isJsonNull()) {

          wrapper.add(key, null);

        } else if (elem.isJsonObject()) {

          wrapper.add(key, deserialize(elem, context));

        } else if (elem.isJsonArray()) {

          JsonArray array = elem.getAsJsonArray();
          List list = new LinkedList();
          for(JsonElement element : array) {
            if (element.isJsonPrimitive()) {
              list.add(fromPrimitive((element.getAsJsonPrimitive())));
            } else if(element.isJsonObject()) {
              // create map of values
              list.add(deserialize(element, context));
            }
          }

          wrapper.add(key, list);

        } else if (elem.isJsonPrimitive()) {

          // wrapper.add(key, elem.getAsString());
          wrapper.add(key, fromPrimitive(elem.getAsJsonPrimitive()));
        }

      }

    } else if(json.isJsonArray()) {

      JsonArray array = json.getAsJsonArray();
      for(JsonElement elem : array) {
        wrapper = new JsonInput();
        if (elem.isJsonPrimitive()) {
          wrapper.add(elem.toString(), fromPrimitive(elem.getAsJsonPrimitive()));
        } else if(elem.isJsonObject()) {
          wrapper.add(elem.toString(), deserialize(elem, context));
        } else if(elem.isJsonArray()) {
          wrapper.add(elem.toString(), deserialize(elem, context));
        }
      }
    }

    return wrapper;
View Full Code Here

Examples of org.structr.core.JsonInput

      Result<T> results = Result.EMPTY_RESULT;
     
      if (source instanceof JsonInput) {

        JsonInput properties = (JsonInput) source;
        PropertyMap map      = PropertyMap.inputTypeToJavaType(securityContext, type, properties.getAttributes());
       
        // If property map contains the uuid, search only for uuid
        if (map.containsKey(GraphObject.id)) {
       
          return (T) app.get(map.get(GraphObject.id));
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.