Esempio n. 1
0
 public static Message decode(InputStream input) {
   try {
     GZIPInputStream zipStream = new GZIPInputStream(input);
     return JsonMessage.decode(new String(IOUtils.toByteArray(zipStream), StandardCharsets.UTF_8));
   } catch (IOException e) {
     throw bomb(e);
   }
 }
 public static ProtocolWaveletDeltaJsoImpl create() {
   ProtocolWaveletDeltaJsoImpl instance =
       (ProtocolWaveletDeltaJsoImpl) JsonMessage.createJsonMessage();
   // Force all lists to start with an empty list rather than no property for
   // the list. This is so that the native JS equality works, since (obviously)
   // {} != {"foo": []} while in the context of messages they should be.
   instance.clearOperation();
   instance.clearAddressPath();
   return instance;
 }
Esempio n. 3
0
 public static byte[] encode(Message msg) {
   String encode = JsonMessage.encode(msg);
   ByteArrayOutputStream bytes = new ByteArrayOutputStream();
   try {
     GZIPOutputStream out = new GZIPOutputStream(bytes);
     out.write(encode.getBytes(StandardCharsets.UTF_8));
     out.finish();
   } catch (IOException e) {
     throw bomb(e);
   }
   return bytes.toByteArray();
 }
Esempio n. 4
0
 /**
  * Compares the current object to another object passed as and argument and returns a boolean
  * value to indicate if the object passed as an argument is a REQUEST
  *
  * @param message the message object to compare to
  * @return boolean true if the argument is a REQUEST, otherwise return false
  */
 public static boolean is(JsonMessage message) {
   return message.getType().equals(REQUEST);
 }