NIOプログラミングのbufferソース学習

2949 ワード

bufferに入ります.JAvaというjavaファイル
 * 

There is one subclass of this class for each non-boolean primitive type.


booleanタイプを除いて、異なるデータ型には対応するサブクラスがあります.
 * 

Transferring data

* *

Each subclass of this class defines two categories of get and * put operations:

* get out *
* *

Relative operations read or write one or more elements starting * at the current position and then increment the position by the number of * elements transferred. position If the requested transfer exceeds the limit then a * relative get operation throws a {@link BufferUnderflowException} * and a relative put operation throws a {@link * BufferOverflowException}; in either case, no data is transferred.

* get limit , BufferUnderflowException put limit , BufferOverflowException *

Absolute operations take an explicit element index and do not * affect the position. Absolute get and put operations throw * an {@link IndexOutOfBoundsException} if the index argument exceeds the * limit.

* ( , position), get put IndexOutOfBoundsException *
* *

Data may also, of course, be transferred in to or out of a buffer by the * I/O operations of an appropriate channel, which are always relative to the * current position.

Marking and resetting

* *

A buffer's mark is the index to which its position will be reset * when the {@link #reset reset} method is invoked. , mark The mark is not always * defined, but when it is defined it is never negative and is never greater * than the position. mark , , position If the mark is defined then it is discarded when the * position or the limit is adjusted to a value smaller than the mark. mark , position limit mark If the * mark is not defined then invoking the {@link #reset reset} method causes an * {@link InvalidMarkException} to be thrown. mark reset ,

Invariants

* *

The following invariant holds for the mark, position, limit, and * capacity values: * *

* 0 <= * mark <= * position <= * limit <= * capacity *
* 0 <= mark <= position <= limit <=capacity *

A newly-created buffer always has a position of zero and a mark that is * undefined. buffer 0 mark The initial limit may be zero, or it may be some other value * that depends upon the type of the buffer and the manner in which it is * constructed. limit 0, , Each element of a newly-allocated buffer is initialized * to zero. buffer