Package com.rabbitmq.client.impl
Class CommandAssembler
- java.lang.Object
-
- com.rabbitmq.client.impl.CommandAssembler
-
final class CommandAssembler extends java.lang.ObjectClass responsible for piecing together a command from a series ofFrames. Concurrency
This class is thread-safe, since all methods are synchronised. Callers should not synchronise on objects of this class unless they are sole owners.- See Also:
AMQCommand
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCommandAssembler.CAStateCurrent state, used to decide how to handle each incoming frame.
-
Field Summary
Fields Modifier and Type Field Description private intbodyLengthsum of the lengths of all fragmentsprivate java.util.List<byte[]>bodyNThe fragments of this command's content body - a list of byte[]private AMQContentHeadercontentHeaderThe content header for this commandprivate static byte[]EMPTY_BYTE_ARRAYprivate intmaxBodyLengthprivate MethodmethodThe method for this commandprivate longremainingBodyBytesNo bytes of content body not yet accumulatedprivate CommandAssembler.CAStatestate
-
Constructor Summary
Constructors Constructor Description CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendBodyFragment(byte[] fragment)private byte[]coalesceContentBody()Stitches together a fragmented content body into a single byte arrayprivate voidconsumeBodyFrame(Frame f)private voidconsumeHeaderFrame(Frame f)private voidconsumeMethodFrame(Frame f)byte[]getContentBody()AMQContentHeadergetContentHeader()MethodgetMethod()booleanhandleFrame(Frame f)booleanisComplete()private voidupdateContentBodyState()Decides whether more body frames are expected
-
-
-
Field Detail
-
EMPTY_BYTE_ARRAY
private static final byte[] EMPTY_BYTE_ARRAY
-
state
private CommandAssembler.CAState state
-
method
private Method method
The method for this command
-
contentHeader
private AMQContentHeader contentHeader
The content header for this command
-
bodyN
private final java.util.List<byte[]> bodyN
The fragments of this command's content body - a list of byte[]
-
bodyLength
private int bodyLength
sum of the lengths of all fragments
-
remainingBodyBytes
private long remainingBodyBytes
No bytes of content body not yet accumulated
-
maxBodyLength
private final int maxBodyLength
-
-
Constructor Detail
-
CommandAssembler
public CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
-
-
Method Detail
-
getMethod
public Method getMethod()
-
getContentHeader
public AMQContentHeader getContentHeader()
-
isComplete
public boolean isComplete()
- Returns:
- true if the command is complete
-
updateContentBodyState
private void updateContentBodyState()
Decides whether more body frames are expected
-
consumeMethodFrame
private void consumeMethodFrame(Frame f) throws java.io.IOException
- Throws:
java.io.IOException
-
consumeHeaderFrame
private void consumeHeaderFrame(Frame f) throws java.io.IOException
- Throws:
java.io.IOException
-
consumeBodyFrame
private void consumeBodyFrame(Frame f)
-
coalesceContentBody
private byte[] coalesceContentBody()
Stitches together a fragmented content body into a single byte array
-
getContentBody
public byte[] getContentBody()
-
appendBodyFragment
private void appendBodyFragment(byte[] fragment)
-
handleFrame
public boolean handleFrame(Frame f) throws java.io.IOException
- Parameters:
f- frame to be incorporated- Returns:
- true if command becomes complete
- Throws:
java.io.IOException- if error reading frame
-
-