@Override public BinaryEncoding getEncoding(final Binary val) { return val.getLength() <= 255 ? _shortBinaryEncoding : _binaryEncoding; }
@Override protected int getEncodedValueSize(final Binary val) { return val.getLength(); }
@Override protected int getEncodedValueSize(final Binary val) { return val.getLength(); }
@Override protected int getEncodedValueSize(final Binary val) { return val.getLength(); }
@Override protected int getEncodedValueSize(final Binary val) { return val.getLength(); }
@Override public Object get(String key) { Object value = messageBodyMap.get(key); if (value instanceof Binary) { // Copy to a byte[], ensure we copy only the required portion. Binary bin = ((Binary) value); value = Arrays.copyOfRange(bin.getArray(), bin.getArrayOffset(), bin.getLength()); } return value; }
@Override public String getUserId() { String userId = null; if (properties != null && properties.getUserId() != null) { Binary userIdBytes = properties.getUserId(); if (userIdBytes.getLength() != 0) { userId = new String(userIdBytes.getArray(), userIdBytes.getArrayOffset(), userIdBytes.getLength(), StandardCharsets.UTF_8); } } return userId; }
@Override public boolean hasBody() { if (bytesOut != null) { return bytesOut.writtenBytes() > 0; } else { return getBinaryFromBody().getLength() != 0; } }
@Override protected void writeEncodedValue(final Binary val) { getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength()); }
@Override protected void writeEncodedValue(final Binary val) { getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength()); }
@Override protected void writeEncodedValue(final Binary val) { getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength()); }
@Override protected void writeEncodedValue(final Binary val) { getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength()); }
/** * Converts a Binary value to a long assuming that the contained value is * stored in Big Endian encoding. * * @param value the Binary object whose payload is converted to a long. * @return a long value constructed from the bytes of the Binary instance. */ public static long toLong(Binary value) { Buffer buffer = new Buffer(value.getArray(), value.getArrayOffset(), value.getLength()); return buffer.bigEndianEditor().readLong(); }