Fields Summary |
---|
static final int | UNSET_MARKUNSET_MARK means the mark has not been set. |
final int | capacityThe capacity of this buffer, which never change. |
int | limitlimit - 1 is the last element that can be read or written.
Limit must be no less than zero and no greater than capacity . |
int | markMark is where position will be set when reset() is called.
Mark is not set by default. Mark is always no less than zero and no
greater than position . |
int | positionThe current position of this buffer. Position is always no less than zero
and no greater than limit . |
int | _elementSizeShiftThe log base 2 of the element size of this buffer. Each typed subclass
(ByteBuffer, CharBuffer, etc.) is responsible for initializing this
value. The value is used by native code to avoid the need for costly
'instanceof' tests. |
Methods Summary |
---|
java.lang.Object | _array()Returns the array associated with this buffer, or null if none exists.
Each typed subclass (ByteBuffer, CharBuffer, etc.) overrides this method
to call its array() method with appropriate checks.
return null;
|
int | _arrayOffset()Returns the offset into the backing array, if one exists, otherwise 0.
Each typed subclass (ByteBuffer, CharBuffer, etc.) overrides this method
to call its arrayOffset() method with appropriate checks.
return 0;
|
public final int | capacity()Returns the capacity of this buffer.
return capacity;
|
public final java.nio.Buffer | clear()Clears 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 cleared.
position = 0;
mark = UNSET_MARK;
limit = capacity;
return this;
|
public final java.nio.Buffer | flip()Flips this buffer.
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.
limit = position;
position = 0;
mark = UNSET_MARK;
return this;
|
public final boolean | hasRemaining()Indicates if there are elements remaining in this buffer, that is if
{@code position < limit}.
return position < limit;
|
public abstract boolean | isReadOnly()Indicates whether this buffer is read-only.
|
public final java.nio.Buffer | limit(int newLimit)Sets the limit of this buffer.
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.
if (newLimit < 0 || newLimit > capacity) {
throw new IllegalArgumentException();
}
limit = newLimit;
if (position > newLimit) {
position = newLimit;
}
if ((mark != UNSET_MARK) && (mark > newLimit)) {
mark = UNSET_MARK;
}
return this;
|
public final int | limit()Returns the limit of this buffer.
return limit;
|
public final java.nio.Buffer | mark()Marks the current position, so that the position may return to this point
later by calling reset() .
mark = position;
return this;
|
public final int | position()Returns the position of this buffer.
return position;
|
public final java.nio.Buffer | position(int newPosition)Sets the position of this buffer.
If the mark is set and it is greater than the new position, then it is
cleared.
if (newPosition < 0 || newPosition > limit) {
throw new IllegalArgumentException();
}
position = newPosition;
if ((mark != UNSET_MARK) && (mark > position)) {
mark = UNSET_MARK;
}
return this;
|
public final int | remaining()Returns the number of remaining elements in this buffer, that is
{@code limit - position}.
return limit - position;
|
public final java.nio.Buffer | reset()Resets the position of this buffer to the mark .
if (mark == UNSET_MARK) {
throw new InvalidMarkException();
}
position = mark;
return this;
|
public final java.nio.Buffer | rewind()Rewinds this buffer.
The position is set to zero, and the mark is cleared. The content of this
buffer is not changed.
position = 0;
mark = UNSET_MARK;
return this;
|