com.rabbitmq.client.impl
Class AMQCommand

java.lang.Object
  extended by com.rabbitmq.client.impl.AMQCommand
All Implemented Interfaces:
Command

public class AMQCommand
extends java.lang.Object
implements Command


Nested Class Summary
 class AMQCommand.Assembler
           
 
Field Summary
static int EMPTY_CONTENT_BODY_FRAME_SIZE
          Safety definition - see also checkEmptyContentBodyFrameSize()
 
Constructor Summary
AMQCommand()
          Construct a command without any method, header or body.
AMQCommand(Method method)
          Construct a command with just a method, and without header or body.
AMQCommand(Method method, AMQContentHeader contentHeader, byte[] body)
          Construct a command with a specified method, header and body.
 
Method Summary
 void appendBodyFragment(byte[] fragment)
           
static void checkEmptyContentBodyFrameSize()
          Private API - Called to check internal consistency of the code.
 void coalesceContentBody()
          Private API - Stitches together a fragmented content body into a single byte array.
 byte[] getContentBody()
          Public API - Retrieves the body byte array that travelled as part of this Command, if any.
 ContentHeader getContentHeader()
          Public API - Retrieves the ContentHeader subclass instance held as part of this Command, if any.
 AMQCommand.Assembler getFreshAssembler()
          Private API - retrieves a fresh Assembler that writes into this AMQCommand.
 Method getMethod()
          Public API - Retrieves the Method held within this Command.
static AMQCommand.Assembler newAssembler()
          Retrieve an Assembler assembling into a fresh AMQCommand object.
 void setContentBody(byte[] body)
          Public API - Set the Command's content body.
 java.lang.String toString()
           
 java.lang.String toString(boolean suppressBody)
           
 void transmit(AMQChannel channel)
          Sends this command down the named channel on the channel's connection, possibly in multiple frames.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_CONTENT_BODY_FRAME_SIZE

public static final int EMPTY_CONTENT_BODY_FRAME_SIZE
Safety definition - see also checkEmptyContentBodyFrameSize()

See Also:
Constant Field Values
Constructor Detail

AMQCommand

public AMQCommand()
Construct a command without any method, header or body.


AMQCommand

public AMQCommand(Method method)
Construct a command with just a method, and without header or body.

Parameters:
method - the wrapped method

AMQCommand

public AMQCommand(Method method,
                  AMQContentHeader contentHeader,
                  byte[] body)
Construct a command with a specified method, header and body.

Parameters:
method - the wrapped method
contentHeader - the wrapped content header
body - the message body data
Method Detail

newAssembler

public static AMQCommand.Assembler newAssembler()
Retrieve an Assembler assembling into a fresh AMQCommand object.

Returns:
the new Assembler

getMethod

public Method getMethod()
Public API - Retrieves the Method held within this Command. Downcast to concrete (implementation-specific!) subclasses as necessary.

Specified by:
getMethod in interface Command
Returns:
the command's method.

getContentHeader

public ContentHeader getContentHeader()
Public API - Retrieves the ContentHeader subclass instance held as part of this Command, if any. Downcast to one of the inner classes of AMQP, for instance AMQP.BasicProperties, as appropriate.

Specified by:
getContentHeader in interface Command
Returns:
the Command's ContentHeader, or null if none

getContentBody

public byte[] getContentBody()
Public API - Retrieves the body byte array that travelled as part of this Command, if any.

Specified by:
getContentBody in interface Command
Returns:
the Command's content body, or null if none

setContentBody

public void setContentBody(byte[] body)
Public API - Set the Command's content body.

Parameters:
body - the body data

appendBodyFragment

public void appendBodyFragment(byte[] fragment)

coalesceContentBody

public void coalesceContentBody()
Private API - Stitches together a fragmented content body into a single byte array.


getFreshAssembler

public AMQCommand.Assembler getFreshAssembler()
Private API - retrieves a fresh Assembler that writes into this AMQCommand.

Returns:
the new Assembler

transmit

public void transmit(AMQChannel channel)
              throws java.io.IOException
Sends this command down the named channel on the channel's connection, possibly in multiple frames.

Parameters:
channel - the channel on which to transmit the command
Throws:
java.io.IOException - if an error is encountered

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean suppressBody)

checkEmptyContentBodyFrameSize

public static void checkEmptyContentBodyFrameSize()
Private API - Called to check internal consistency of the code. Since we're using a precomputed value for EMPTY_CONTENT_BODY_FRAME_SIZE, we check here once, at connection startup, that EMPTY_CONTENT_BODY_FRAME_SIZE is actually correct when run against the framing code in Frame.