Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.nio
Class Buffer  view Buffer download Buffer.java

java.lang.Object
  extended byjava.nio.Buffer
Direct Known Subclasses:
ByteBuffer, CharBuffer, DoubleBuffer, FloatBuffer, IntBuffer, LongBuffer, ShortBuffer

public abstract class Buffer
extends java.lang.Object

Since:
1.4

Field Summary
(package private)  gnu.classpath.Pointer address
           
(package private)  int cap
           
(package private)  int limit
           
(package private)  int mark
           
(package private)  int pos
           
 
Constructor Summary
(package private) Buffer(int capacity, int limit, int position, int mark)
          Creates a new Buffer.
 
Method Summary
 int capacity()
          Retrieves the capacity of the buffer.
(package private) static void checkArraySize(int arraylength, int offset, int length)
          Checks whether an array is large enough to hold the given number of elements at the given offset.
(package private)  void checkForOverflow()
          Checks for overflow.
(package private)  void checkForOverflow(int length)
          Checks for overflow.
(package private)  void checkForUnderflow()
          Checks for underflow.
(package private)  void checkForUnderflow(int length)
          Checks for underflow.
(package private)  void checkIfReadOnly()
          Checks if buffer is read-only.
(package private)  void checkIndex(int index)
          Checks if index is negative or not smaller than the buffer's limit.
 Buffer clear()
          Clears the buffer.
 Buffer flip()
          Flips the buffer.
 boolean hasRemaining()
          Tells whether the buffer has remaining data to read or not.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cap

int cap

limit

int limit

pos

int pos

mark

int mark

address

gnu.classpath.Pointer address
Constructor Detail

Buffer

Buffer(int capacity,
       int limit,
       int position,
       int mark)
Creates a new Buffer. Should be package private.

Method Detail

capacity

public final int capacity()
Retrieves the capacity of the buffer.


clear

public final Buffer clear()
Clears the buffer.


flip

public final Buffer flip()
Flips the buffer.


hasRemaining

public final boolean hasRemaining()
Tells whether the buffer has remaining data to read or not.


isReadOnly

public abstract boolean isReadOnly()
Tells whether this buffer is read only or not.


limit

public final int limit()
Retrieves the current limit of the buffer.


limit

public final Buffer limit(int newLimit)
Sets this buffer's limit.


mark

public final Buffer mark()
Sets this buffer's mark at its position.


position

public final int position()
Retrieves the current position of this buffer.


position

public final Buffer position(int newPosition)
Sets this buffer's position. If the mark is defined and larger than the new position then it is discarded.


remaining

public final int remaining()
Returns the number of elements between the current position and the limit.


reset

public final Buffer reset()
Resets this buffer's position to the previously-marked position.


rewind

public final Buffer rewind()
Rewinds this buffer. The position is set to zero and the mark is discarded.


checkForUnderflow

final void checkForUnderflow()
Checks for underflow. This method is used internally to check whether a buffer has enough elements left to satisfy a read request.


checkForUnderflow

final void checkForUnderflow(int length)
Checks for underflow. This method is used internally to check whether a buffer has enough elements left to satisfy a read request for a given number of elements.


checkForOverflow

final void checkForOverflow()
Checks for overflow. This method is used internally to check whether a buffer has enough space left to satisfy a write request.


checkForOverflow

final void checkForOverflow(int length)
Checks for overflow. This method is used internally to check whether a buffer has enough space left to satisfy a write request for a given number of elements.


checkIndex

final void checkIndex(int index)
Checks if index is negative or not smaller than the buffer's limit. This method is used internally to check whether an indexed request can be fulfilled.


checkIfReadOnly

final void checkIfReadOnly()
Checks if buffer is read-only. This method is used internally to check if elements can be put into a buffer.


checkArraySize

static final void checkArraySize(int arraylength,
                                 int offset,
                                 int length)
Checks whether an array is large enough to hold the given number of elements at the given offset. This method is used internally to check if an array is big enough.