@Override public void put(ReadableBuffer buffer) { buffer.get(this); } }
byte readRawByte() { return _buffer.get(); }
void readRaw(final byte[] data, final int offset, final int length) { _buffer.get(data, offset, length); }
@Override public void put(ReadableBuffer buffer) { buffer.get(this); } }
@Override public void put(ReadableBuffer src) { src.get(this); }
@Override public void put(ReadableBuffer buffer) { buffer.get(this); }
@Override public void put(ReadableBuffer src) { ensureCapacity(position); src.get(this); }
@Override public void put(ReadableBuffer src) { ensureCapacity(position); src.get(this); }
private static boolean equals(byte[] buffer, int start, int length, ReadableBuffer other) { final int position = other.position(); for (int i = 0; i < length; i++) { if (buffer[start + i] != other.get(position + i)) { return false; } } return true; }
@Override public Date readTimestamp(final Date defaultValue) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.TIMESTAMP: return new Date(readRawLong()); case EncodingCodes.NULL: return defaultValue; default: throw new ProtonException("Expected Timestamp type but found encoding: " + encodingCode); } }
@Override public Float readFloat(final Float defaultVal) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.FLOAT: return Float.valueOf(readRawFloat()); case EncodingCodes.NULL: return defaultVal; default: throw new ProtonException("Expected Float type but found encoding: " + encodingCode); } }
private ReadableBuffer completePartial(final ReadableBuffer finalContent) { int pending = finalContent.remaining(); if(pending > 0) { byte[] chunk = new byte[pending]; finalContent.get(chunk); splitContent.append(chunk); } ReadableBuffer data = splitContent; splitContent = null; return data; }
@Override public Decimal32 readDecimal32(final Decimal32 defaultValue) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.DECIMAL32: return (Decimal32) _constructors[EncodingCodes.DECIMAL32 & 0xff].readValue(); case EncodingCodes.NULL: return defaultValue; default: throw new ProtonException("Expected Decimal32 type but found encoding: " + encodingCode); } }
@Override public Decimal128 readDecimal128(final Decimal128 defaultValue) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.DECIMAL128: return (Decimal128) _constructors[EncodingCodes.DECIMAL128 & 0xff].readValue(); case EncodingCodes.NULL: return defaultValue; default: throw new ProtonException("Expected Decimal128 type but found encoding: " + encodingCode); } }
@Override public Byte readByte(final Byte defaultVal) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.BYTE: return (Byte) readRawByte(); case EncodingCodes.NULL: return defaultVal; default: throw new DecodeException("Expected byte type but found encoding: " + encodingCode); } }
@Override public UUID readUUID(final UUID defaultVal) { byte encodingCode = _buffer.get(); switch (encodingCode) { case EncodingCodes.UUID: return new UUID(readRawLong(), readRawLong()); case EncodingCodes.NULL: return defaultVal; default: throw new ProtonException("Expected UUID type but found encoding: " + encodingCode); } }
@Override public void put(ReadableBuffer buffer) { if (buffer.hasArray()) { nettyBuffer.writeBytes(buffer.array(), buffer.arrayOffset(), buffer.remaining()); } else { while (buffer.hasRemaining()) { nettyBuffer.writeByte(buffer.get()); } } } }
@Override public void put(ReadableBuffer payload) { final int toCopy = payload.remaining(); ensureRemaining(toCopy); if (payload.hasArray()) { System.arraycopy(payload.array(), payload.arrayOffset() + payload.position(), array, position, toCopy); payload.position(payload.position() + toCopy); } else { payload.get(array, position, toCopy); } position += toCopy; }
@Override public org.apache.activemq.artemis.api.core.Message copy() { ensureDataIsValid(); ReadableBuffer view = data.duplicate().rewind(); byte[] newData = new byte[view.remaining()]; // Copy the full message contents with delivery annotations as they will // be trimmed on send and may become useful on the broker at a later time. view.get(newData); AMQPMessage newEncode = new AMQPMessage(this.messageFormat, newData, extraProperties, coreMessageObjectPools); newEncode.setMessageID(this.getMessageID()); return newEncode; }