public interface BufferFacade
ByteBuffer
(typically for testing) or a MappedFileBuffer
.
All methods use a long
index. However, depending on the actual
implementation, index values may be limited to Integer.MAX_VALUE
.
Modifier and Type | Method and Description |
---|---|
long |
capacity()
Returns the capacity of the wrapped buffer.
|
byte |
get(long index)
Returns the single byte at the specified index (relative to the
relocation base).
|
byte[] |
getBytes(long index,
int len)
Returns an array containing the
len bytes starting
at the specified index (relative to the relocation base). |
char |
getChar(long index)
Returns the 2-byte
char value at the specified index
(relative to the relocation base). |
double |
getDouble(long index)
Returns the 8-byte
double value at the specified index
(relative to the relocation base). |
float |
getFloat(long index)
Returns the 4-byte
float value at the specified index
(relative to the relocation base). |
int |
getInt(long index)
Returns the 4-byte
int value at the specified index
(relative to the relocation base). |
long |
getLong(long index)
Returns the 8-byte
long value at the specified index
(relative to the relocation base). |
short |
getShort(long index)
Returns the 2-byte
short value at the specified index
(relative to the relocation base). |
long |
limit()
Returns the limit of the buffer: the highest legal index + 1.
|
void |
put(long index,
byte value)
Updates the single byte at the specified index (relative to the
relocation base).
|
void |
putBytes(long index,
byte[] value)
Inserts the specified array into the buffer, starting at the given
index (relative to the relocation base).
|
void |
putChar(long index,
char value)
Sets the 2-byte
char value at the specified index
(relative to the relocation base). |
void |
putDouble(long index,
double value)
Sets the 8-byte
double value at the specified index
(relative to the relocation base). |
void |
putFloat(long index,
float value)
Sets the 4-byte
float value at the specified index
(relative to the relocation base). |
void |
putInt(long index,
int value)
Sets the 4-byte
int value at the specified index
(relative to the relocation base). |
void |
putLong(long index,
long value)
Sets the 8-byte
long value at the specified index
(relative to the relocation base). |
void |
putShort(long index,
short value)
Sets the 2-byte
short value at the specified index
(relative to the relocation base). |
ByteBuffer |
slice(long index)
Returns a
ByteBuffer that represents a slice of the
underlying buffer (ie, shares the same backing store), starting at
the given index (relative to the relocation base) and extending to
the end of the underlying buffer. |
byte get(long index)
void put(long index, byte value)
short getShort(long index)
short
value at the specified index
(relative to the relocation base).void putShort(long index, short value)
short
value at the specified index
(relative to the relocation base).int getInt(long index)
int
value at the specified index
(relative to the relocation base).void putInt(long index, int value)
int
value at the specified index
(relative to the relocation base).long getLong(long index)
long
value at the specified index
(relative to the relocation base).void putLong(long index, long value)
long
value at the specified index
(relative to the relocation base).float getFloat(long index)
float
value at the specified index
(relative to the relocation base).void putFloat(long index, float value)
float
value at the specified index
(relative to the relocation base).double getDouble(long index)
double
value at the specified index
(relative to the relocation base).void putDouble(long index, double value)
double
value at the specified index
(relative to the relocation base).char getChar(long index)
char
value at the specified index
(relative to the relocation base).void putChar(long index, char value)
char
value at the specified index
(relative to the relocation base).byte[] getBytes(long index, int len)
len
bytes starting
at the specified index (relative to the relocation base).void putBytes(long index, byte[] value)
ByteBuffer slice(long index)
ByteBuffer
that represents a slice of the
underlying buffer (ie, shares the same backing store), starting at
the given index (relative to the relocation base) and extending to
the end of the underlying buffer.
The semantics of this method depend on the underlying buffer. For a
normal ByteBuffer
, the limit will be determined by the
size of the original buffer. For a MappedFileBuffer
,
the limit will depend on the particular segment containing the offset.
long capacity()
long limit()
capacity()
.
Support for this method will depend on the underlying buffer's support
for limits. MappedFileBuffer
does not support limits, and will
always return capacity. The non-threadsafe facade created by BufferFacadeFactory
does support limits, but the threadsafe facade
only supports limits that were set before the first facade method
was invoked (because it clones the buffer).