Package com.rabbitmq.client.impl
Class CommandAssembler
- java.lang.Object
-
- com.rabbitmq.client.impl.CommandAssembler
-
final class CommandAssembler extends java.lang.Object
Class responsible for piecing together a command from a series ofFrame
s. 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 class
CommandAssembler.CAState
Current state, used to decide how to handle each incoming frame.
-
Field Summary
Fields Modifier and Type Field Description private int
bodyLength
sum of the lengths of all fragmentsprivate java.util.List<byte[]>
bodyN
The fragments of this command's content body - a list of byte[]private AMQContentHeader
contentHeader
The content header for this commandprivate static byte[]
EMPTY_BYTE_ARRAY
private int
maxBodyLength
private Method
method
The method for this commandprivate long
remainingBodyBytes
No bytes of content body not yet accumulatedprivate CommandAssembler.CAState
state
-
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 void
appendBodyFragment(byte[] fragment)
private byte[]
coalesceContentBody()
Stitches together a fragmented content body into a single byte arrayprivate void
consumeBodyFrame(Frame f)
private void
consumeHeaderFrame(Frame f)
private void
consumeMethodFrame(Frame f)
byte[]
getContentBody()
AMQContentHeader
getContentHeader()
Method
getMethod()
boolean
handleFrame(Frame f)
boolean
isComplete()
private void
updateContentBodyState()
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
-
-