public static AMQPHeader getAMQP(IByteBuffer buf)
        {
            TLVAmqp list = TLVFactory.getTlv(buf);

            if (list.Code != AMQPType.LIST_0 && list.Code != AMQPType.LIST_8 && list.Code != AMQPType.LIST_32)
            {
                throw new MalformedMessageException("Received amqp-header with malformed arguments");
            }

            AMQPHeader header = null;

            Byte        byteCode = list.Constructor.getDescriptorCode().Value;
            HeaderCodes code     = (HeaderCodes)byteCode;

            switch (code)
            {
            case HeaderCodes.ATTACH:
                header = new AMQPAttach();
                break;

            case HeaderCodes.BEGIN:
                header = new AMQPBegin();
                break;

            case HeaderCodes.CLOSE:
                header = new AMQPClose();
                break;

            case HeaderCodes.DETACH:
                header = new AMQPDetach();
                break;

            case HeaderCodes.DISPOSITION:
                header = new AMQPDisposition();
                break;

            case HeaderCodes.END:
                header = new AMQPEnd();
                break;

            case HeaderCodes.FLOW:
                header = new AMQPFlow();
                break;

            case HeaderCodes.OPEN:
                header = new AMQPOpen();
                break;

            case HeaderCodes.TRANSFER:
                header = new AMQPTransfer();
                break;

            default:
                throw new MalformedMessageException("Received amqp-header with unrecognized performative");
            }

            header.fillArguments((TLVList)list);

            return(header);
        }
        public static AMQPHeader getSASL(IByteBuffer buf)
        {
            TLVAmqp list = TLVFactory.getTlv(buf);

            if (list.Code != AMQPType.LIST_0 && list.Code != AMQPType.LIST_8 && list.Code != AMQPType.LIST_32)
            {
                throw new MalformedMessageException("Received amqp-header with malformed arguments");
            }

            AMQPHeader header = null;

            Byte        byteCode = list.Constructor.getDescriptorCode().Value;
            HeaderCodes code     = (HeaderCodes)byteCode;

            switch (code)
            {
            case HeaderCodes.CHALLENGE:
                header = new SASLChallenge();
                break;

            case HeaderCodes.INIT:
                header = new SASLInit();
                break;

            case HeaderCodes.MECHANISMS:
                header = new SASLMechanisms();
                break;

            case HeaderCodes.OUTCOME:
                header = new SASLOutcome();
                break;

            case HeaderCodes.RESPONSE:
                header = new SASLResponse();
                break;

            default:
                throw new MalformedMessageException("Received sasl-header with unrecognized arguments code");
            }

            header.fillArguments((TLVList)list);

            return(header);
        }