Package net.sf.cindy

Examples of net.sf.cindy.Buffer.limit()


    public void testSlice() {
        Buffer buffer = newBuffer(8);
        buffer.putInt(123);
        Buffer slice = buffer.slice();
        assertEquals(0, slice.position());
        assertEquals(4, slice.limit());
        assertEquals(4, slice.capacity());
        assertEquals(4, buffer.position());
        assertEquals(8, buffer.limit());
        assertEquals(8, buffer.capacity());
View Full Code Here


        assertEquals(4, slice.position());

        buffer.flip();
        slice = buffer.slice();
        assertEquals(0, slice.position());
        assertEquals(8, slice.limit());
        assertEquals(123, slice.getInt());
        assertEquals(num, slice.getInt());
        assertFalse(slice.hasRemaining());
    }
View Full Code Here

    private short decodeShort(int index) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 2)
            return buffer.getShort(idx);
        return Bits.decodeShort(this, index);
    }

    private Buffer encodeShort(int index, short s) {
View Full Code Here

    private Buffer encodeShort(int index, short s) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 2)
            buffer.putShort(idx, s);
        else
            Bits.encodeShort(this, index, s);
        return this;
    }
View Full Code Here

    private int decodeInt(int index) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 4)
            return buffer.getInt(idx);
        return Bits.decodeInt(this, index);
    }

    private Buffer encodeInt(int index, int i) {
View Full Code Here

    private Buffer encodeInt(int index, int i) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 4)
            buffer.putInt(idx, i);
        else
            Bits.encodeInt(this, index, i);
        return this;
    }
View Full Code Here

    private long decodeLong(int index) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 8)
            return buffer.getLong(idx);
        return Bits.decodeLong(this, index);
    }

    private Buffer encodeLong(int index, long l) {
View Full Code Here

    private Buffer encodeLong(int index, long l) {
        Entry entry = getEntry(index);
        Buffer buffer = entry.buffer;

        int idx = buffer.position() + index - entry.position;
        if (buffer.limit() - idx >= 8)
            buffer.putLong(idx, l);
        else
            Bits.encodeLong(this, index, l);
        return this;
    }
View Full Code Here

                        SocketAddress address = channel.receive(byteBuffer);
                        if (address == null) {
                            buffer.release();
                            break;
                        }
                        buffer.limit(byteBuffer.position());
                        getSessionFilterChain(false).packetReceived(
                                new DefaultPacket(buffer, address));
                    } catch (IOException e) {
                        buffer.release();
                        throw e;
View Full Code Here

    }

    public Object decode(Session session, Packet packet) throws Exception {
        Buffer content = packet.getContent();
        int position = content.position();
        int limit = content.limit();

        for (Iterator iter = chain.iterator(); iter.hasNext();) {
            PacketDecoder decoder = (PacketDecoder) iter.next();
            Object obj = decoder.decode(session, packet);
            if (obj != null)
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.