public int encode(WritableBuffer buffer)
{
int length = buffer.remaining();
DecoderImpl decoder = new DecoderImpl();
EncoderImpl encoder = new EncoderImpl(decoder);
AMQPDefinedTypes.registerAllTypes(decoder);
encoder.setByteBuffer(buffer);
if(getHeader() != null)
{
encoder.writeObject(getHeader());
}
if(getDeliveryAnnotations() != null)
{
encoder.writeObject(getDeliveryAnnotations());
}
if(getMessageAnnotations() != null)
{
encoder.writeObject(getDeliveryAnnotations());
}
if(getProperties() != null)
{
encoder.writeObject(getProperties());
}
if(getApplicationProperties() != null)
{
encoder.writeObject(getApplicationProperties());
}
if(getBody() != null)
{
encoder.writeObject(getBody());
}
if(getFooter() != null)
{
encoder.writeObject(getFooter());
}
return length - buffer.remaining();
}