Examples of BBEncoder


Examples of org.apache.qpid.transport.codec.BBEncoder

    // The super clas methods resets the buffer
    @ Override
    public ByteBuffer getData()
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeMap(getMap());
        return encoder.segment();
    }
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        method(method, SegmentType.COMMAND);
    }

    private void method(Method method, SegmentType type)
    {
        BBEncoder enc = _encoder.get();
        enc.init();
        enc.writeUint16(method.getEncodedType());
        if (type == SegmentType.COMMAND)
        {
            if (method.isSync())
            {
                enc.writeUint16(0x0101);
            }
            else
            {
                enc.writeUint16(0x0100);
            }
        }
        method.write(enc);
        int methodLimit = enc.position();

        byte flags = FIRST_SEG;

        boolean payload = method.hasPayload();
        if (!payload)
        {
            flags |= LAST_SEG;
        }

        int headerLimit = -1;
        if (payload)
        {
            final Header hdr = method.getHeader();
            if (hdr != null)
            {
                if(hdr.getDeliveryProperties() != null)
                {
                    enc.writeStruct32(hdr.getDeliveryProperties());
                }
                if(hdr.getMessageProperties() != null)
                {
                    enc.writeStruct32(hdr.getMessageProperties());
                }
                if(hdr.getNonStandardProperties() != null)
                {
                    for (Struct st : hdr.getNonStandardProperties())
                    {
                        enc.writeStruct32(st);
                    }
                }
            }
            headerLimit = enc.position();
        }

        synchronized (sendlock)
        {
            ByteBuffer buf = enc.underlyingBuffer();
            buf.position(0);
            buf.limit(methodLimit);

            fragment(flags, type, method, buf);
            if (payload)
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        }
    }

    public ByteBuffer getData() throws JMSException
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeList(_list);
        return encoder.segment();
    }
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

    /**
     * Builds an empty  management message.
     */
    ManagementMessage()
    {
        _codec = new BBEncoder(100);
        _codec.writeMagicNumber();
    }
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        return buf;
    }

    private void method(Method method, SegmentType type)
    {
        BBEncoder enc = encoder.get();
        enc.init();
        enc.writeUint16(method.getEncodedType());
        if (type == SegmentType.COMMAND)
        {
            if (method.isSync())
            {
                enc.writeUint16(0x0101);
            }
            else
            {
                enc.writeUint16(0x0100);
            }
        }
        method.write(enc);
        ByteBuffer methodSeg = enc.segment();

        byte flags = FIRST_SEG;

        boolean payload = method.hasPayload();
        if (!payload)
        {
            flags |= LAST_SEG;
        }

        ByteBuffer headerSeg = null;
        if (payload)
        {
            final Header hdr = method.getHeader();
            if (hdr != null)
            {
                final Struct[] structs = hdr.getStructs();

                for (Struct st : structs)
                {
                    enc.writeStruct32(st);
                }
            }
            headerSeg = enc.segment();
        }

        synchronized (sendlock)
        {
            fragment(flags, type, method, methodSeg);
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

    // The super clas methods resets the buffer
    @ Override
    public ByteBuffer getData()
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeMap(_map);
        return encoder.segment();
    }
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        }
    }

    public void testListBehaviorForIncommingMsg() throws Exception
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeList(_list);
        AMQPEncodedListMessage m = new AMQPEncodedListMessage(new AMQMessageDelegate_0_10(),encoder.segment());

        assertTrue("contains(Object) method did not return true as expected",m.contains(1));
        assertFalse("contains(Object) method did not return false as expected",m.contains(5));
        assertEquals("get(index) method returned incorrect value",((Integer)m.get(1)).intValue(),2);
        assertEquals("indexOf(Object) method returned incorrect index",m.indexOf(2),1);
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        }
    }

    public void testStreamMessageInterfaceForIncommingMsg() throws Exception
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeList(getList());
        AMQPEncodedListMessage m = new AMQPEncodedListMessage(new AMQMessageDelegate_0_10(),encoder.segment());

        assertEquals(true,m.readBoolean());
        assertEquals((byte)256,m.readByte());
        assertEquals(Short.MAX_VALUE,m.readShort());
        assertEquals(Integer.MAX_VALUE,m.readInt());
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        assertEquals(_uuid,(UUID)m.readObject());
    }

    public void testMapMessageInterfaceForIncommingMsg() throws Exception
    {
        BBEncoder encoder = new BBEncoder(1024);
        encoder.writeList(getList());
        AMQPEncodedListMessage m = new AMQPEncodedListMessage(new AMQMessageDelegate_0_10(),encoder.segment());

        assertEquals(true,m.getBoolean("0"));
        assertEquals((byte)256,m.getByte("1"));
        assertEquals(Short.MAX_VALUE,m.getShort("2"));
        assertEquals(Integer.MAX_VALUE,m.getInt("3"));
View Full Code Here

Examples of org.apache.qpid.transport.codec.BBEncoder

        return buf.limit();
    }

    private ByteBuffer encodeAsBuffer()
    {
        BBEncoder encoder = new BBEncoder(ENCODER_SIZE);

        encoder.writeInt64(_arrivalTime);
        encoder.writeInt32(_bodySize);
        int headersLength = 0;
        if(_header.getDeliveryProperties() != null)
        {
            headersLength++;
        }
        if(_header.getMessageProperties() != null)
        {
            headersLength++;
        }
        if(_header.getNonStandardProperties() != null)
        {
            headersLength += _header.getNonStandardProperties().size();
        }

        encoder.writeInt32(headersLength);

        if(_header.getDeliveryProperties() != null)
        {
            encoder.writeStruct32(_header.getDeliveryProperties());
        }
        if(_header.getMessageProperties() != null)
        {
            encoder.writeStruct32(_header.getMessageProperties());
        }
        if(_header.getNonStandardProperties() != null)
        {

            for(Struct header : _header.getNonStandardProperties())
            {
                encoder.writeStruct32(header);
            }

        }
        ByteBuffer buf = encoder.buffer();
        return buf;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.