Package com.caucho.json

Examples of com.caucho.json.JsonOutput


                      String to,
                      String from,
                      Serializable value)
  {
    try {
      JsonOutput out = _out;
     
      if (out == null)
        return;
     
      out.init(os);
     
      if (log.isLoggable(Level.FINER)) {
        log.finer(this + " message " + value
                  + " {to:" + to + ", from:" + from + "}");
      }
     

      os.print("[\"message\"");
     
      if (to != null) {
        os.print(",\"");
        os.print(to);
        os.print("\"");
      }
      else {
        os.print(",null");
      }
       
      if (from != null) {
        os.print(",\"");
        os.print(from);
        os.print("\"");
      }
      else {
        os.print(",null");
      }
     
      os.print(",\"");
      writeType(os, value);
      os.print("\"");

      os.print(",");
      out.writeObject(value);
      out.flushBuffer();
      os.write("]");
    } catch (IOException e) {
      throw new ProtocolException(e);
    }
  }
View Full Code Here


                           String from,
                           Serializable value,
                           BamError error)
  {
    try {
      JsonOutput out = _out;

      if (out == null)
        return;
     
      out.init(os);
     
      if (log.isLoggable(Level.FINER)) {
        log.finer(this + " messageError " + value
                  + " {to:" + to + ", from:" + from + "}");
      }

      os.print("[\"message_error\",\"");

      os.print(to);
       
      os.write("\",\"");

      os.print(from);
     
      os.write("\",\"");

      writeType(os, value);
       
      os.write("\",");

      out.writeObject(value);
      out.flushBuffer();
      os.write(",");
      out.writeObject(error);
      out.flushBuffer();
      os.write("]");
    } catch (IOException e) {
      throw new ProtocolException(e);
    }
  }
View Full Code Here

                    String to,
                    String from,
                    Serializable value)
  {
    try {
      JsonOutput out = _out;

      if (out == null)
        return;
     
      out.init(os);
     
      if (log.isLoggable(Level.FINER)) {
        log.finer(this + " query " + value
                  + " {id: " + id + ", to:" + to + ", from:" + from + "}");
      }

      os.print("[\"query\"");
       
      if (to != null) {
        os.print(",\"");
        os.print(to);
        os.print("\"");
      }
      else {
        os.print(",null");
      }

      if (from != null) {
        os.print(",\"");
        os.print(from);
        os.print("\"");
      }
      else {
        os.print(",null");
      }

      os.print(",");
      os.print(id);
     
      os.write(",\"");
      writeType(os, value);

      os.print("\",");
      out.writeObject(value);
      out.flushBuffer();

      os.print("]");
    } catch (IOException e) {
      throw new ProtocolException(e);
    }
View Full Code Here

                          String to,
                          String from,
                          Serializable value)
  {
    try {
      JsonOutput out = _out;

      if (out == null)
        return;
     
      out.init(os);
     
      if (log.isLoggable(Level.FINER)) {
        log.finer(this + " result " + value
                  + " {id: " + id + ", to:" + to + ", from:" + from + "}");
      }

      os.print("[\"result\"");

      if (to != null) {
        os.print(",\"");
        os.print(to);
        os.print("\"");
      }
      else {
        os.print(",null");
      }

      if (from != null) {
        os.print(",\"");
        os.print(from);
        os.print("\"");
      }
      else {
        os.print(",null");
      }

      os.print(",");
      os.print(id);

      os.write(",\"");
      writeType(os, value);
     
      os.print("\",");
      out.writeObject(value);
      out.flushBuffer();

      os.print("]");
    } catch (IOException e) {
      throw new ProtocolException(e);
    }
View Full Code Here

                         String from,
                         Serializable payload,
                         BamError error)
  {
    try {
      JsonOutput out = _out;

      if (out == null)
        return;
     
      out.init(os);
     
      if (log.isLoggable(Level.FINER)) {
        log.finer(this + " query_error " + error + "\n  " + payload + "\n  "
                  + " {id: " + id + ", to:" + to + ", from:" + from + "}");
      }

      os.print("[\"query_error\"");

      if (to != null) {
        os.print(",\"");
        os.print(to);
        os.print("\"");
      }
      else {
        os.print(",null");
      }

      if (from != null) {
        os.print(",\"");
        os.print(from);
        os.print("\"");
      }

      os.print(",");
      os.print(id);


      os.write(",\"");
      writeType(os, payload);
     
      os.print("\",");
      out.writeObject(payload);
      out.flushBuffer();

      os.print(",");
      out.writeObject(error);
      out.flushBuffer();

      os.print("]");
    } catch (IOException e) {
      throw new ProtocolException(e);
    }
View Full Code Here

  }

  public void flush()
    throws IOException
  {
    JsonOutput out = _out;

    if (out != null) {
      out.flush();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.json.JsonOutput

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.