protected int getSizeOf(FieldTable table) { return EncodingUtils.encodedFieldTableLength(table); //To change body of created methods use File | Settings | File Templates. }
@Override public int getEncodingSize() { return EncodingUtils.encodedLongLength(); } }
protected int getSizeOf(AMQShortString string) { return EncodingUtils.encodedShortStringLength(string); }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedByteLength() + EncodingUtils.encodedIntegerLength(); }
/** * Reads an instance of the type from a specified byte buffer. * * @param buffer The byte buffer to write it to. * * @return An instance of the type. */ @Override public Object readValueFromBuffer(QpidByteBuffer buffer) { try { // Read size of field table then all name/value pairs. return EncodingUtils.readFieldTable(buffer); } catch (AMQFrameDecodingException e) { throw new IllegalArgumentException("Unable to read field table from buffer.", e); } }
@Override public int getStorableSize() { int size = _contentHeaderBody.getSize(); size += 4; size += EncodingUtils.encodedShortStringLength(_messagePublishInfo.getExchange()); size += EncodingUtils.encodedShortStringLength(_messagePublishInfo.getRoutingKey()); size += 1; // flags for immediate/mandatory size += EncodingUtils.encodedLongLength(); return size; }
size += EncodingUtils.encodedShortStringLength(_contentType); size += EncodingUtils.encodedShortStringLength(_encoding); size += EncodingUtils.encodedFieldTableLength(_headers); size += EncodingUtils.encodedShortStringLength(_correlationId); size += EncodingUtils.encodedShortStringLength(_replyTo); size += EncodingUtils.encodedShortStringLength(ZERO_STRING); size += EncodingUtils.encodedShortStringLength(_expiration); size += EncodingUtils.encodedShortStringLength(_messageId); size += EncodingUtils.encodedShortStringLength(_type); size += EncodingUtils.encodedShortStringLength(_userId); size += EncodingUtils.encodedShortStringLength(_appId); size += EncodingUtils.encodedShortStringLength(_clusterId);
EncodingUtils.writeShortStringBytes(buffer, _contentType); EncodingUtils.writeShortStringBytes(buffer, _encoding); EncodingUtils.writeFieldTableBytes(buffer, _headers); EncodingUtils.writeShortStringBytes(buffer, _correlationId); EncodingUtils.writeShortStringBytes(buffer, _replyTo); EncodingUtils.writeShortStringBytes(buffer, ZERO_STRING); EncodingUtils.writeLongAsShortString(buffer, _expiration); EncodingUtils.writeShortStringBytes(buffer, _messageId); EncodingUtils.writeShortStringBytes(buffer, _type); EncodingUtils.writeShortStringBytes(buffer, _userId); EncodingUtils.writeShortStringBytes(buffer, _appId); EncodingUtils.writeShortStringBytes(buffer, _clusterId);
public static void process(final QpidByteBuffer in, final ClientMethodProcessor dispatcher) throws AMQFrameDecodingException { short versionMajor = in.getUnsignedByte(); short versionMinor = in.getUnsignedByte(); FieldTable serverProperties = EncodingUtils.readFieldTable(in); byte[] mechanisms = EncodingUtils.readBytes(in); byte[] locales = EncodingUtils.readBytes(in); if(!dispatcher.ignoreAllButCloseOk()) { dispatcher.receiveConnectionStart(versionMajor, versionMinor, serverProperties, mechanisms, locales); } if (serverProperties != null) { serverProperties.clearEncodedForm(); } } }
protected void writeAMQShortString(QpidByteBuffer buffer, AMQShortString string) { EncodingUtils.writeShortStringBytes(buffer, string); }
public static void writeLongStringBytes(QpidByteBuffer buffer, String s) { if (s != null) { int len = getUTF8Length(s); buffer.putUnsignedInt((long) len); buffer.put(asUTF8Bytes(s)); } else { buffer.putUnsignedInt((long) 0); } }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedByteLength(); }
static AMQShortString valueOf(Object obj, boolean truncate, boolean nullAsEmptyString) { if (obj == null) { if (nullAsEmptyString) { return EMPTY_STRING; } return null; } else { String value = String.valueOf(obj); int strLength = Math.min(value.length(), AMQShortString.MAX_LENGTH); byte[] bytes = EncodingUtils.asUTF8Bytes(value); if(truncate) { while (bytes.length > AMQShortString.MAX_LENGTH) { value = value.substring(0, strLength-- - 3) + "..."; bytes = EncodingUtils.asUTF8Bytes(value); } } return createAMQShortString(bytes); } }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedDoubleLength(); }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedBooleanLength(); }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedCharLength(); }
public static void process(final QpidByteBuffer buffer, final ClientChannelMethodProcessor dispatcher) throws AMQFrameDecodingException { int replyCode = buffer.getUnsignedShort(); AMQShortString replyText = AMQShortString.readAMQShortString(buffer); FieldTable details = EncodingUtils.readFieldTable(buffer); if(!dispatcher.ignoreAllButCloseOk()) { dispatcher.receiveChannelAlert(replyCode, replyText, details); } if (details != null) { details.clearEncodedForm(); } } }
public static void process(final QpidByteBuffer in, final ServerMethodProcessor dispatcher) throws AMQFrameDecodingException { FieldTable clientProperties = EncodingUtils.readFieldTable(in); AMQShortString mechanism = AMQShortString.readAMQShortString(in); byte[] response = EncodingUtils.readBytes(in); AMQShortString locale = AMQShortString.readAMQShortString(in); if(!dispatcher.ignoreAllButCloseOk()) { dispatcher.receiveConnectionStartOk(clientProperties, mechanism, response, locale); } if (clientProperties != null) { clientProperties.clearEncodedForm(); } } }
private void putDataInBuffer(QpidByteBuffer buffer) { if (_encodedForm != null) { byte[] encodedCopy = new byte[_encodedForm.remaining()]; _encodedForm.copyTo(encodedCopy); buffer.put(encodedCopy); } else if (!_properties.isEmpty()) { for (final Map.Entry<String, AMQTypedValue> me : _properties.entrySet()) { EncodingUtils.writeShortStringBytes(buffer, me.getKey()); me.getValue().writeToBuffer(buffer); } } }
@Override public int getEncodingSize(Object value) { return EncodingUtils.encodedByteLength(); }