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; }
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(); }
/** * 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); }