public final class DirectReadWriteByteBuffer extends DirectByteBuffer
DirectReadWriteByteBuffer extends DirectByteBuffer with all the write methods.
This class is marked final for runtime performance.
| Constructor and Description |
|---|
DirectReadWriteByteBuffer(elemental2.core.ArrayBuffer backingArray) |
DirectReadWriteByteBuffer(elemental2.core.ArrayBuffer backingArray,
int capacity,
int arrayOffset) |
DirectReadWriteByteBuffer(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
CharBuffer |
asCharBuffer()
Returns a char buffer which is based on the remaining content of this
byte buffer.
|
DoubleBuffer |
asDoubleBuffer()
Returns a double buffer which is based on the remaining content of this
byte buffer.
|
FloatBuffer |
asFloatBuffer()
Returns a float buffer which is based on the remaining content of this
byte buffer.
|
IntBuffer |
asIntBuffer()
Returns a int buffer which is based on the remaining content of this byte
buffer.
|
LongBuffer |
asLongBuffer()
Returns a long buffer which is based on the remaining content of this
byte buffer.
|
ByteBuffer |
asReadOnlyBuffer()
Returns a read-only buffer that shares its content with this buffer.
|
ShortBuffer |
asShortBuffer()
Returns a short buffer which is based on the remaining content of this
byte buffer.
|
ByteBuffer |
compact()
Compacts this byte buffer.
|
ByteBuffer |
duplicate()
Returns a duplicated buffer that shares its content with this buffer.
|
char |
getChar()
Returns the char at the current position and increases the position by 2.
|
char |
getChar(int index)
Returns the char at the specified index.
|
boolean |
isReadOnly()
Indicates whether this buffer is read-only.
|
protected byte[] |
protectedArray()
Child class implements this method to realize
array(). |
protected int |
protectedArrayOffset()
Child class implements this method to realize
arrayOffset(). |
protected boolean |
protectedHasArray()
Child class implements this method to realize
hasArray(). |
ByteBuffer |
put(byte b)
Writes the given byte to the current position and increases the position
by 1.
|
ByteBuffer |
put(byte[] src,
int off,
int len)
Writes bytes in the given byte array, starting from the specified offset,
to the current position and increases the position by the number of bytes
written.
|
ByteBuffer |
put(int index,
byte b)
Write a byte to the specified index of this buffer without changing the
position.
|
ByteBuffer |
putChar(char value)
Writes the given char to the current position and increases the position
by 2.
|
ByteBuffer |
putChar(int index,
char value)
Writes the given char to the specified index of this buffer.
|
ByteBuffer |
putDouble(double value)
Writes the given double to the current position and increases the position
by 8.
|
ByteBuffer |
putDouble(int index,
double value)
Writes the given double to the specified index of this buffer.
|
ByteBuffer |
putFloat(float value)
Writes the given float to the current position and increases the position
by 4.
|
ByteBuffer |
putFloat(int index,
float value)
Writes the given float to the specified index of this buffer.
|
ByteBuffer |
putInt(int value)
Writes the given int to the current position and increases the position by
4.
|
ByteBuffer |
putInt(int index,
int value)
Writes the given int to the specified index of this buffer.
|
ByteBuffer |
putLong(int index,
long value)
Writes the given long to the specified index of this buffer.
|
ByteBuffer |
putLong(long value)
Writes the given long to the current position and increases the position
by 8.
|
ByteBuffer |
putShort(int index,
short value)
Writes the given short to the specified index of this buffer.
|
ByteBuffer |
putShort(short value)
Writes the given short to the current position and increases the position
by 2.
|
ByteBuffer |
slice()
Returns a sliced buffer that shares its content with this buffer.
|
get, get, get, getDouble, getDouble, getElementSize, getElementType, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getTypedArray, isDirect, loadInt, loadLong, loadShort, store, store, storeallocate, allocateDirect, array, arrayOffset, compareTo, equals, get, hasArray, hashCode, order, order, put, put, stringToByteBuffer, toString, wrap, wrappublic DirectReadWriteByteBuffer(elemental2.core.ArrayBuffer backingArray)
public DirectReadWriteByteBuffer(int capacity)
public DirectReadWriteByteBuffer(elemental2.core.ArrayBuffer backingArray,
int capacity,
int arrayOffset)
public FloatBuffer asFloatBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
public IntBuffer asIntBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
public ShortBuffer asShortBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
public ByteBuffer asReadOnlyBuffer()
ByteBufferThe returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, limit, capacity and mark are the same as this buffer.
The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.
asReadOnlyBuffer in class ByteBufferpublic ByteBuffer compact()
ByteBuffer
The remaining bytes will be moved to the head of the
buffer, starting from position zero. Then the position is set to
remaining(); the limit is set to capacity; the mark is
cleared.
compact in class ByteBufferpublic ByteBuffer duplicate()
ByteBufferThe duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only property and byte order are the same as this buffer's too.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
duplicate in class ByteBufferpublic boolean isReadOnly()
BufferisReadOnly in class Buffertrue if this buffer is read-only, false
otherwise.protected byte[] protectedArray()
ByteBufferarray().ByteBuffer.array()protected int protectedArrayOffset()
ByteBufferarrayOffset().ByteBuffer.arrayOffset()protected boolean protectedHasArray()
ByteBufferhasArray().ByteBuffer.hasArray()public ByteBuffer put(byte b)
ByteBufferput in class ByteBufferb - the byte to write.public ByteBuffer put(int index, byte b)
ByteBufferput in class ByteBufferindex - the index, must not be negative and less than the limit.b - the byte to write.public ByteBuffer put(byte[] src, int off, int len)
ByteBufferput in class ByteBuffersrc - the source byte array.off - the offset of byte array, must not be negative and not greater
than src.length.len - the number of bytes to write, must not be negative and not
greater than src.length - off.public ByteBuffer putDouble(double value)
ByteBufferThe double is converted to bytes using the current byte order.
putDouble in class ByteBuffervalue - the double to write.public ByteBuffer putDouble(int index, double value)
ByteBufferThe double is converted to bytes using the current byte order. The position is not changed.
putDouble in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 8.value - the double to write.public ByteBuffer putFloat(float value)
ByteBufferThe float is converted to bytes using the current byte order.
putFloat in class ByteBuffervalue - the float to write.public ByteBuffer putFloat(int index, float value)
ByteBufferThe float is converted to bytes using the current byte order. The position is not changed.
putFloat in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 4.value - the float to write.public ByteBuffer putInt(int value)
ByteBufferThe int is converted to bytes using the current byte order.
putInt in class ByteBuffervalue - the int to write.public ByteBuffer putInt(int index, int value)
ByteBufferThe int is converted to bytes using the current byte order. The position is not changed.
putInt in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 4.value - the int to write.public ByteBuffer putLong(int index, long value)
ByteBufferThe long is converted to bytes using the current byte order. The position is not changed.
putLong in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 8.value - the long to write.public ByteBuffer putLong(long value)
ByteBufferThe long is converted to bytes using the current byte order.
putLong in class ByteBuffervalue - the long to write.public ByteBuffer putShort(int index, short value)
ByteBufferThe short is converted to bytes using the current byte order. The position is not changed.
putShort in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 2.value - the short to write.public ByteBuffer putShort(short value)
ByteBufferThe short is converted to bytes using the current byte order.
putShort in class ByteBuffervalue - the short to write.public ByteBuffer slice()
ByteBuffer
The sliced buffer's capacity will be this buffer's
remaining(), and it's zero position will correspond to
this buffer's current position. The new buffer's position will be 0,
limit will be its capacity, and its mark is cleared. The new buffer's
read-only property and byte order are the same as this buffer's.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
slice in class ByteBufferpublic CharBuffer asCharBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
asCharBuffer in class ByteBufferpublic DoubleBuffer asDoubleBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
asDoubleBuffer in class ByteBufferpublic LongBuffer asLongBuffer()
ByteBufferThe new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
asLongBuffer in class ByteBufferpublic final char getChar()
ByteBufferThe 2 bytes starting at the current position are composed into a char according to the current byte order and returned.
getChar in class ByteBufferpublic final char getChar(int index)
ByteBufferThe 2 bytes starting from the specified index are composed into a char according to the current byte order and returned. The position is not changed.
getChar in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 2.public final ByteBuffer putChar(char value)
ByteBufferThe char is converted to bytes using the current byte order.
putChar in class ByteBuffervalue - the char to write.public final ByteBuffer putChar(int index, char value)
ByteBufferThe char is converted to bytes using the current byte order. The position is not changed.
putChar in class ByteBufferindex - the index, must not be negative and equal or less than
limit - 2.value - the char to write.Copyright © 2020 Dmitrii Tikhomirov. All rights reserved.