Java ByteBuffer Set setCell(ByteBuffer buffer, int cellIndex, int cellbytes)

Here you can find the source of setCell(ByteBuffer buffer, int cellIndex, int cellbytes)

Description

Positions the given buffer at the start of the specified cell.

License

Apache License

Parameter

Parameter Description
cellIndex zero based cell index (starts at the beginning of the <tt>buffer</tt>)
cellbytes number of bytes in each buffer

Return

buffer

Declaration

public static ByteBuffer setCell(ByteBuffer buffer, int cellIndex, int cellbytes) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    /**/*from ww  w . j ava2  s.  co  m*/
     * Positions the given <tt>buffer</tt> at the start of the specified cell. Arguments
     * are not checked.
     * <pre><tt>
     *   int position = cellIndex * cellbytes;
     *   int limit = position + cellbytes;
     *   buffer.limit(limit).position(position);
     * </tt></pre>
     * 
     * 
     * @param cellIndex
     *        zero based cell index (starts at the beginning of the <tt>buffer</tt>)
     * @param cellbytes
     *        number of bytes in each buffer
     * @return
     *        <tt>buffer</tt>
     */
    public static ByteBuffer setCell(ByteBuffer buffer, int cellIndex, int cellbytes) {
        int position = cellIndex * cellbytes;
        int limit = position + cellbytes;
        buffer.limit(limit).position(position);
        return buffer;
    }
}

Related

  1. set0byte(MappedByteBuffer mem, byte value)
  2. set24BitInt(ByteBuffer buffer, int value)
  3. setBatch(ByteBuffer bb, long batchId)
  4. setByteOrder(ByteBuffer buffer)
  5. setBytesAtOffset(ByteBuffer buffer, int offset, int length, byte[] data)
  6. setCreationTime(ByteBuffer buf, Date date)
  7. setFree(int frameIx, int offset, boolean free, ByteBuffer[] frames)
  8. setLimIfNeeded(ByteBuffer bb, int lim)
  9. setLong(ByteBuffer buffer, long data)