Java Code Examples for io.vertx.core.json.JsonObject#readFromBuffer()

The following examples show how to use io.vertx.core.json.JsonObject#readFromBuffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceExceptionMessageCodec.java    From vertx-service-proxy with Apache License 2.0 6 votes vote down vote up
@Override
public ServiceException decodeFromWire(int pos, Buffer buffer) {
  int failureCode = buffer.getInt(pos);
  pos += 4;
  boolean isNull = buffer.getByte(pos) == (byte)0;
  pos++;
  String message;
  if (!isNull) {
    int strLength = buffer.getInt(pos);
    pos += 4;
    byte[] bytes = buffer.getBytes(pos, pos + strLength);
    message = new String(bytes, CharsetUtil.UTF_8);
    pos += strLength;
  } else {
    message = null;
  }
  JsonObject debugInfo = new JsonObject();
  debugInfo.readFromBuffer(pos, buffer);
  return new ServiceException(failureCode, message, debugInfo);
}
 
Example 2
Source File: UserImpl.java    From vertx-auth with Apache License 2.0 5 votes vote down vote up
@Override
public int readFromBuffer(int pos, Buffer buffer) {
  JsonObject jsonObject = new JsonObject();
  int read = jsonObject.readFromBuffer(pos, buffer);
  User readUser = UserConverter.decode(jsonObject);
  this.principal = readUser.principal();
  this.authorizations = readUser.authorizations();
  this.attributes = readUser.attributes();
  return read;
}