|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.faunos.util.io.ImmutableBuffer
public class ImmutableBuffer
A ByteBuffer holder that exposes an immutable view of it.
The point here is that a buffer's position and limit are part of its state,
so read-only buffers in fact have mutable state. This class is an attempt
to lock down that part of a buffer's state so that we can, for
example, create such things as thread-safe, buffer "constants".
| Constructor Summary | |
|---|---|
ImmutableBuffer(ByteBuffer buffer)
Creates a new instance based on the remaining bytes in the given buffer. |
|
ImmutableBuffer(ByteBuffer buffer,
boolean slice)
Creates a new instance based on the remaining bytes in the given buffer. |
|
| Method Summary | |
|---|---|
ByteBuffer |
buffer()
Returns a new, read-only view of the contained buffer. |
int |
size()
Returns the byte size of the buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ImmutableBuffer(ByteBuffer buffer)
buffer - the buffer from which the read-only view is constructed. The
caller agrees not to change the position or limit of
the input buffer.
public ImmutableBuffer(ByteBuffer buffer,
boolean slice)
slice - if true, then the buffer is sliced even if the
remaining number of bytes and capacity of the buffer
are the same; o.w. (false) the caller is implicitly
agreeing not to ever change the position or limit of the input
buffer.| Method Detail |
|---|
public final ByteBuffer buffer()
public final int size()
buffer().remaining().
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||