java.lang.Object | ||
java.nio.Buffer |
A buffer is a list of elements of a specific primitive type.
A buffer can be described by following properties:
limit - 1
. Accessing
elements out of the scope will cause exception. Limit is no less than zero
and no greater than capacity.ReadOnlyBufferException
, while
changing the position, limit and mark of a readonly buffer is OK.Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.
final | int | capacity() | ||||
Returns the capacity of this buffer. | ||||||
final | Buffer | clear() | ||||
Clears this buffer. | ||||||
final | Buffer | flip() | ||||
Flips this buffer. | ||||||
final | boolean | hasRemaining() | ||||
Returns true if there are remaining element(s) in this buffer. | ||||||
abstract | boolean | isReadOnly() | ||||
Returns whether this buffer is readonly or not. | ||||||
final | int | limit() | ||||
Returns the limit of this buffer. | ||||||
final | Buffer | limit(int newLimit) | ||||
Sets the limit of this buffer. | ||||||
final | Buffer | mark() | ||||
Mark the current position, so that the position may return to this point
later by calling reset() . |
||||||
final | int | position() | ||||
Returns the position of this buffer. | ||||||
final | Buffer | position(int newPosition) | ||||
Sets the position of this buffer. | ||||||
final | int | remaining() | ||||
Returns the number of remaining elements in this buffer. | ||||||
final | Buffer | reset() | ||||
Reset the position of this buffer to the mark . |
||||||
final | Buffer | rewind() | ||||
Rewinds this buffer. |
While the content of this buffer is not changed the following internal changes take place : the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is unset.
The limit is set to the current position, then the position is set to zero, and the mark is cleared.
The content of this buffer is not changed.
Or more precisely, returns position < limit
.
If the current position in the buffer is in excess of
newLimit
then, on returning from this call, it will have
been adjusted to be equivalent to newLimit
. If the mark
is set and is greater than the new limit, then it is cleared.
newLimit | The new limit, must be no less than zero and no greater than capacity |
---|
IllegalArgumentException | If newLimit is invalid.
|
---|
reset()
.
If the mark is set and is greater than the new position, then it is cleared.
newPosition | The new position, must be no less than zero and no greater than limit |
---|
IllegalArgumentException | If newPosition is invalid
|
---|
Or more precisely, returns limit - position
.
mark
.
InvalidMarkException | If the mark is not set |
---|
The position is set to zero, and the mark is cleared.
The content of this buffer is not changed.
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |