public static class BufferFacadeFactory.ByteBufferFacade extends Object implements BufferFacade
ByteBuffer
.Constructor and Description |
---|
ByteBufferFacade(ByteBuffer buf) |
ByteBufferFacade(ByteBuffer buf,
int base) |
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. |
public ByteBufferFacade(ByteBuffer buf)
public ByteBufferFacade(ByteBuffer buf, int base)
public byte get(long index)
BufferFacade
get
in interface BufferFacade
public void put(long index, byte value)
BufferFacade
put
in interface BufferFacade
public short getShort(long index)
BufferFacade
short
value at the specified index
(relative to the relocation base).getShort
in interface BufferFacade
public void putShort(long index, short value)
BufferFacade
short
value at the specified index
(relative to the relocation base).putShort
in interface BufferFacade
public int getInt(long index)
BufferFacade
int
value at the specified index
(relative to the relocation base).getInt
in interface BufferFacade
public void putInt(long index, int value)
BufferFacade
int
value at the specified index
(relative to the relocation base).putInt
in interface BufferFacade
public long getLong(long index)
BufferFacade
long
value at the specified index
(relative to the relocation base).getLong
in interface BufferFacade
public void putLong(long index, long value)
BufferFacade
long
value at the specified index
(relative to the relocation base).putLong
in interface BufferFacade
public float getFloat(long index)
BufferFacade
float
value at the specified index
(relative to the relocation base).getFloat
in interface BufferFacade
public void putFloat(long index, float value)
BufferFacade
float
value at the specified index
(relative to the relocation base).putFloat
in interface BufferFacade
public double getDouble(long index)
BufferFacade
double
value at the specified index
(relative to the relocation base).getDouble
in interface BufferFacade
public void putDouble(long index, double value)
BufferFacade
double
value at the specified index
(relative to the relocation base).putDouble
in interface BufferFacade
public char getChar(long index)
BufferFacade
char
value at the specified index
(relative to the relocation base).getChar
in interface BufferFacade
public void putChar(long index, char value)
BufferFacade
char
value at the specified index
(relative to the relocation base).putChar
in interface BufferFacade
public byte[] getBytes(long index, int len)
BufferFacade
len
bytes starting
at the specified index (relative to the relocation base).getBytes
in interface BufferFacade
public void putBytes(long index, byte[] value)
BufferFacade
putBytes
in interface BufferFacade
public ByteBuffer slice(long index)
BufferFacade
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.
slice
in interface BufferFacade
public long capacity()
BufferFacade
capacity
in interface BufferFacade
public long limit()
BufferFacade
BufferFacade.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).
limit
in interface BufferFacade