Package net.sf.cindy

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


    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);
    }
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);
    }
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);
    }
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

    }

    private String _getString(int i, Charset charset, int bufferLen) {
        Buffer buffer = BufferFactory.allocate(bufferLen);
        batch(true, i, buffer, bufferLen);
        buffer.position(0);
        try {
            return charset.decode(buffer.asByteBuffer());
        } finally {
            buffer.release();
        }
View Full Code Here

        Buffer buffer = (Buffer) obj;
        if (this.remaining() != buffer.remaining())
            return false;
        int start = getIndex(0);
        int end = start + remaining();
        for (int i = start, j = buffer.position(); i < end; i++, j++) {
            if (_get(i) != buffer.get(j))
                return false;
        }
        return true;
    }
View Full Code Here

        return this;
    }

    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);
View Full Code Here

            if (obj != null)
                return obj;

            // not use slice to create new buffer, reduce memory cost
            content.limit(limit);
            content.position(position);
        }
        return 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.