Package java.nio

Examples of java.nio.ByteBuffer.slice()


                @Override
                public int getContent(int offsetInMessage, ByteBuffer dst)
                {
                    ByteBuffer buf = allData.duplicate();
                    buf.position(offsetInMessage);
                    buf = buf.slice();
                    int size;
                    if(dst.remaining()<buf.remaining())
                    {
                        buf.limit(dst.remaining());
                        size = dst.remaining();
View Full Code Here


                @Override
                public ByteBuffer getContent(int offsetInMessage, int size)
                {
                    ByteBuffer buf = allData.duplicate();
                    buf.position(offsetInMessage);
                    buf = buf.slice();
                    if(size < buf.remaining())
                    {
                        buf.limit(size);
                    }
                    return buf;
View Full Code Here

            ByteBuffer data = ByteBuffer.wrap(cb.getData());
            if(offset+written >= pos && offset < pos + data.limit())
            {
                ByteBuffer src = data.duplicate();
                src.position(offset+written - pos);
                src = src.slice();

                if(buf.remaining() < src.limit())
                {
                    src.limit(buf.remaining());
                }
View Full Code Here

        @Override
        public ByteBuffer read(int position, int length) {
            ByteBuffer entry = buffer.asReadOnlyBuffer();
            entry.position(entry.position() + position);
            entry.limit(entry.position() + length);
            return entry.slice();
        }

        @Override
        public void close() {
        }
View Full Code Here

    protected void reset(Block block, int count)
    {
        ByteBuffer bb = block.getByteBuffer() ;
        bb.clear() ;
        bb.position(headerLength) ;
        bb = bb.slice();
        this.recBuff = new RecordBuffer(bb, factory, count) ;
    }

    public final RecordBuffer getRecordBuffer()
    {
View Full Code Here

            if (encoding != DataBlockEncoding.NONE) {
              // We expect a two-byte big-endian encoding id.
              assertEquals(0, actualBuffer.get(0));
              assertEquals(encoding.getId(), actualBuffer.get(1));
              actualBuffer.position(2);
              actualBuffer = actualBuffer.slice();
            }

            ByteBuffer expectedBuffer = encodedBlocks.get(blockId);
            expectedBuffer.rewind();
View Full Code Here

    public int getContent(int offset, ByteBuffer dst)
    {
        ByteBuffer src = _content.duplicate();
        src.position(offset);
        src = src.slice();
        if(dst.remaining() < src.limit())
        {
            src.limit(dst.remaining());
        }
        dst.put(src);
View Full Code Here

                buf.rewind();

                if (first) {
                    first = false;
                    buf.position(getTag().length() + getCommand().length() + 2);
                    buf = buf.slice();
                }
                return buf;
            }

            public void remove() {
View Full Code Here

          throw new RuntimeException("you need to seekTo() before calling getValue()");
        }
        // TODO: Could this be done with one ByteBuffer rather than create two?
        ByteBuffer valueBuff = this.block.slice();
        valueBuff.position(this.currKeyLen);
        valueBuff = valueBuff.slice();
        valueBuff.limit(currValueLen);
        valueBuff.rewind();
        return valueBuff;
      }
View Full Code Here

            {
                dp.setTimestamp(System.currentTimeMillis());
            }

            ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED,
                                new Header(dp, mp), body.slice());
            count++;
        }

        ssn.messageCancel("echo-queue");
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.