Java Utililty Methods ByteBuffer Set

List of utility methods to do ByteBuffer Set

Description

The list of methods to do ByteBuffer Set are organized into topic(s).

Method

voidsetBytesAtOffset(ByteBuffer buffer, int offset, int length, byte[] data)
Given a java.nio.ByteBuffer set bytes in an absolute offset without altering its current position.
synchronized (buffer) {
    int position = buffer.position();
    buffer.position(offset);
    buffer.put(data, 0, length);
    buffer.position(position);
ByteBuffersetCell(ByteBuffer buffer, int cellIndex, int cellbytes)
Positions the given buffer at the start of the specified cell.
int position = cellIndex * cellbytes;
int limit = position + cellbytes;
buffer.limit(limit).position(position);
return buffer;
voidsetCreationTime(ByteBuffer buf, Date date)
Set the creation date.
Calendar cal = Calendar.getInstance();
if (date != null)
    cal.setTime(date);
fillBufFromTime(buf, cal);
voidsetFree(int frameIx, int offset, boolean free, ByteBuffer[] frames)
set Free
if (free) { 
    frames[frameIx].put(offset, (byte) (((frames[frameIx]).array()[offset]) | 0x80));
} else { 
    frames[frameIx].put(offset, (byte) (((frames[frameIx]).array()[offset]) & 0x7F));
voidsetLimIfNeeded(ByteBuffer bb, int lim)
To avoid useless/dangerous(concurrency) writes.
if (bb.limit() != lim) {
    bb.limit(lim);
voidsetLong(ByteBuffer buffer, long data)
set Long
assert (buffer.capacity() - buffer.position() >= 8);
buffer.put((byte) (data & 0x00000000000000ffl));
buffer.put((byte) ((data & 0x000000000000ff00l) >>> 8));
buffer.put((byte) ((data & 0x0000000000ff0000l) >>> 16));
buffer.put((byte) ((data & 0x00000000ff000000l) >>> 24));
buffer.put((byte) ((data & 0x000000ff00000000l) >>> 32));
buffer.put((byte) ((data & 0x0000ff0000000000l) >>> 40));
buffer.put((byte) ((data & 0x00ff000000000000l) >>> 48));
...
voidsetSByte(ByteBuffer buffer, byte data)
set S Byte
assert (buffer.capacity() - buffer.position() >= 1);
buffer.put(data);
voidsetSInt(ByteBuffer buffer, int data)
set S Int
assert (buffer.capacity() - buffer.position() >= 4);
buffer.put((byte) (data & 0x000000ffl));
buffer.put((byte) ((data & 0x0000ff00l) >> 8));
buffer.put((byte) ((data & 0x00ff0000l) >> 16));
buffer.put((byte) ((data & 0xff000000l) >> 24));
voidsetString(ByteBuffer buffer, int index)
set String
byte[] data = new byte[buffer.capacity()];
for (int i = 0; i < data.length; i++) {
    data[i] = 'x';
String _index = "" + index;
byte[] __index = _index.getBytes();
for (int i = 0; i < __index.length; i++) {
    data[i] = __index[i];
...
voidsetString(ByteBuffer buffer, String data)
set String
assert (null != data);
byte[] bytes = data.getBytes();
assert (buffer.capacity() - buffer.position() >= Array.getLength(bytes));
buffer.put(bytes);
buffer.put((byte) 0);