public abstract class Buffer extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
abstract java.lang.Object |
array()
Returns the backing array of this buffer, if this buffer has one.
|
abstract int |
arrayOffset()
For buffers that are backed by a Java array, this returns the offset
into that array at which the buffer content starts.
|
int |
capacity()
Retrieves the capacity of the buffer.
|
Buffer |
clear()
Clears the buffer.
|
Buffer |
flip()
Flips the buffer.
|
abstract boolean |
hasArray()
Returns
true if this buffer can provide a backing array,
false otherwise. |
boolean |
hasRemaining()
Tells whether the buffer has remaining data to read or not.
|
abstract boolean |
isDirect()
Returns
true when this buffer is direct, false
otherwise. |
abstract boolean |
isReadOnly()
Tells whether this buffer is read only or not.
|
int |
limit()
Retrieves the current limit of the buffer.
|
Buffer |
limit(int newLimit)
Sets this buffer's limit.
|
Buffer |
mark()
Sets this buffer's mark at its position.
|
int |
position()
Retrieves the current position of this buffer.
|
Buffer |
position(int newPosition)
Sets this buffer's position.
|
int |
remaining()
Returns the number of elements between the current position and the limit.
|
Buffer |
reset()
Resets this buffer's position to the previously-marked position.
|
Buffer |
rewind()
Rewinds this buffer.
|
public final int capacity()
public final boolean hasRemaining()
public abstract boolean isReadOnly()
public final int limit()
public final Buffer limit(int newLimit)
newLimit - The new limit value; must be non-negative and no larger
than this buffer's capacity.java.lang.IllegalArgumentException - If the preconditions on newLimit
do not hold.public final int position()
public final Buffer position(int newPosition)
newPosition - The new position value; must be non-negative and no
larger than the current limit.java.lang.IllegalArgumentException - If the preconditions on newPosition
do not holdpublic final int remaining()
public final Buffer reset()
InvalidMarkException - If the mark has not been set.public final Buffer rewind()
public abstract java.lang.Object array()
If this is a read-only buffer, then a ReadOnlyBufferException is
thrown because exposing the array would allow to circumvent the read-only
property. If this buffer doesn't have an array, then an
UnsupportedOperationException is thrown. Applications should check
if this buffer supports a backing array by calling hasArray()
first.
ReadOnlyBufferException - when this buffer is read onlyjava.lang.UnsupportedOperationException - when this buffer does not provide
a backing arraypublic abstract boolean hasArray()
true if this buffer can provide a backing array,
false otherwise. When true, application code
can call array() to access this backing array.true if this buffer can provide a backing array,
false otherwisepublic abstract int arrayOffset()
ReadOnlyBufferException - when this buffer is read onlyjava.lang.UnsupportedOperationException - when this buffer does not provide
a backing arraypublic abstract boolean isDirect()
true when this buffer is direct, false
otherwise. A direct buffer is usually backed by a raw memory area instead
of a Java array.true when this buffer is direct, false
otherwise