Class CommandAssembler


  • final class CommandAssembler
    extends java.lang.Object
    Class responsible for piecing together a command from a series of Frames.

    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
    • Field Detail

      • EMPTY_BYTE_ARRAY

        private static final byte[] EMPTY_BYTE_ARRAY
      • 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()
      • 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