|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.Buffer
java.nio.ByteBuffer
java.nio.MappedByteBuffer
java.nio.DirectByteBuffer
java.nio.DirectByteBufferR
| Field Summary | |
protected static boolean |
unaligned
|
protected static sun.misc.Unsafe |
unsafe
|
protected Object |
viewedBuffer
|
| Fields inherited from class java.nio.MappedByteBuffer |
isAMappedBuffer |
| Fields inherited from class java.nio.ByteBuffer |
bigEndian, hb, isReadOnly, nativeByteOrder, offset |
| Fields inherited from class java.nio.Buffer |
address |
| Constructor Summary | |
(package private) |
DirectByteBufferR(sun.nio.ch.DirectBuffer db,
int mark,
int pos,
int lim,
int cap,
int off)
|
(package private) |
DirectByteBufferR(int cap)
|
protected |
DirectByteBufferR(int cap,
long addr,
Runnable unmapper)
|
| Method Summary | |
(package private) byte |
_get(int i)
|
(package private) void |
_put(int i,
byte b)
|
long |
address()
|
CharBuffer |
asCharBuffer()
Creates a view of this byte buffer as a char buffer. |
DoubleBuffer |
asDoubleBuffer()
Creates a view of this byte buffer as a double buffer. |
FloatBuffer |
asFloatBuffer()
Creates a view of this byte buffer as a float buffer. |
IntBuffer |
asIntBuffer()
Creates a view of this byte buffer as an int buffer. |
LongBuffer |
asLongBuffer()
Creates a view of this byte buffer as a long buffer. |
ByteBuffer |
asReadOnlyBuffer()
Creates a new, read-only byte buffer that shares this buffer's content. |
ShortBuffer |
asShortBuffer()
Creates a view of this byte buffer as a short buffer. |
sun.misc.Cleaner |
cleaner()
|
ByteBuffer |
compact()
Compacts this buffer (optional operation). |
ByteBuffer |
duplicate()
Creates a new byte buffer that shares this buffer's content. |
byte |
get()
Relative get method. |
ByteBuffer |
get(byte[] dst,
int offset,
int length)
Relative bulk get method. |
byte |
get(int i)
Absolute get method. |
char |
getChar()
Relative get method for reading a char value. |
char |
getChar(int i)
Absolute get method for reading a char value. |
double |
getDouble()
Relative get method for reading a double value. |
double |
getDouble(int i)
Absolute get method for reading a double value. |
float |
getFloat()
Relative get method for reading a float value. |
float |
getFloat(int i)
Absolute get method for reading a float value. |
int |
getInt()
Relative get method for reading an int value. |
int |
getInt(int i)
Absolute get method for reading an int value. |
long |
getLong()
Relative get method for reading a long value. |
long |
getLong(int i)
Absolute get method for reading a long value. |
short |
getShort()
Relative get method for reading a short value. |
short |
getShort(int i)
Absolute get method for reading a short value. |
boolean |
isDirect()
Tells whether or not this byte buffer is direct. |
boolean |
isReadOnly()
Tells whether or not this buffer is read-only. |
ByteBuffer |
put(byte x)
Relative put method (optional operation). |
ByteBuffer |
put(byte[] src,
int offset,
int length)
Relative bulk put method (optional operation). |
ByteBuffer |
put(ByteBuffer src)
Relative bulk put method (optional operation). |
ByteBuffer |
put(int i,
byte x)
Absolute put method (optional operation). |
ByteBuffer |
putChar(char x)
Relative put method for writing a char value (optional operation). |
ByteBuffer |
putChar(int i,
char x)
Absolute put method for writing a char value (optional operation). |
private ByteBuffer |
putChar(long a,
char x)
|
ByteBuffer |
putDouble(double x)
Relative put method for writing a double value (optional operation). |
ByteBuffer |
putDouble(int i,
double x)
Absolute put method for writing a double value (optional operation). |
private ByteBuffer |
putDouble(long a,
double x)
|
ByteBuffer |
putFloat(float x)
Relative put method for writing a float value (optional operation). |
ByteBuffer |
putFloat(int i,
float x)
Absolute put method for writing a float value (optional operation). |
private ByteBuffer |
putFloat(long a,
float x)
|
ByteBuffer |
putInt(int x)
Relative put method for writing an int value (optional operation). |
ByteBuffer |
putInt(int i,
int x)
Absolute put method for writing an int value (optional operation). |
private ByteBuffer |
putInt(long a,
int x)
|
ByteBuffer |
putLong(int i,
long x)
Absolute put method for writing a long value (optional operation). |
ByteBuffer |
putLong(long x)
Relative put method for writing a long value (optional operation). |
private ByteBuffer |
putLong(long a,
long x)
|
ByteBuffer |
putShort(int i,
short x)
Absolute put method for writing a short value (optional operation). |
private ByteBuffer |
putShort(long a,
short x)
|
ByteBuffer |
putShort(short x)
Relative put method for writing a short value (optional operation). |
ByteBuffer |
slice()
Creates a new byte buffer whose content is a shared subsequence of this buffer's content. |
Object |
viewedBuffer()
|
| Methods inherited from class java.nio.MappedByteBuffer |
force, isLoaded, load |
| Methods inherited from class java.nio.ByteBuffer |
allocate, allocateDirect, array, arrayOffset, compareTo, equals, get, hasArray, hashCode, order, order, put, toString, wrap, wrap |
| Methods inherited from class java.nio.Buffer |
capacity, checkBounds, checkIndex, checkIndex, clear, flip, hasRemaining, limit, limit, mark, markValue, nextGetIndex, nextGetIndex, nextPutIndex, nextPutIndex, position, position, remaining, reset, rewind |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface sun.nio.ch.DirectBuffer |
address, cleaner, viewedBuffer |
| Field Detail |
protected static final sun.misc.Unsafe unsafe
protected static final boolean unaligned
protected Object viewedBuffer
| Constructor Detail |
DirectByteBufferR(int cap)
protected DirectByteBufferR(int cap,
long addr,
Runnable unmapper)
DirectByteBufferR(sun.nio.ch.DirectBuffer db,
int mark,
int pos,
int lim,
int cap,
int off)
| Method Detail |
public ByteBuffer slice()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
slice in class DirectByteBufferpublic ByteBuffer duplicate()
ByteBufferThe content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
duplicate in class DirectByteBufferpublic ByteBuffer asReadOnlyBuffer()
ByteBufferThe content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffers' position, limit, and mark values will be independent.
The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.
If this buffer is itself read-only then this method behaves in
exactly the same way as the duplicate method.
asReadOnlyBuffer in class DirectByteBufferpublic ByteBuffer put(byte x)
ByteBufferWrites the given byte into this buffer at the current position, and then increments the position.
put in class DirectByteBuffer
public ByteBuffer put(int i,
byte x)
ByteBufferWrites the given byte into this buffer at the given index.
put in class DirectByteBufferpublic ByteBuffer put(ByteBuffer src)
ByteBuffer This method transfers the bytes remaining in the given source
buffer into this buffer. If there are more bytes remaining in the
source buffer than in this buffer, that is, if
src.remaining() > remaining(),
then no bytes are transferred and a BufferOverflowException is thrown.
Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop
while (src.hasRemaining())
dst.put(src.get());
except that it first checks that there is sufficient space in this
buffer and it is potentially much more efficient.
put in class DirectByteBuffer
public ByteBuffer put(byte[] src,
int offset,
int length)
ByteBuffer This method transfers bytes into this buffer from the given
source array. If there are more bytes to be copied from the array
than remain in this buffer, that is, if
length > remaining(), then no
bytes are transferred and a BufferOverflowException is
thrown.
Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.
In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop
for (int i = off; i < off + len; i++)
dst.put(a[i]);
except that it first checks that there is sufficient space in this
buffer and it is potentially much more efficient.
put in class DirectByteBufferpublic ByteBuffer compact()
ByteBufferThe bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.
The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
Invoke this method after writing data from a buffer in case the write was incomplete. The following loop, for example, copies bytes from one channel to another via the buffer buf:
buf.clear(); // Prepare buffer for use
for (;;) {
if (in.read(buf) < 0 && !buf.hasRemaining())
break; // No more bytes to transfer
buf.flip();
out.write(buf);
buf.compact(); // In case of partial write
}
compact in class DirectByteBufferpublic boolean isDirect()
ByteBuffer
isDirect in class DirectByteBufferpublic boolean isReadOnly()
Buffer
isReadOnly in class DirectByteBufferbyte _get(int i)
_get in class DirectByteBuffer
void _put(int i,
byte b)
_put in class DirectByteBuffer
private ByteBuffer putChar(long a,
char x)
public ByteBuffer putChar(char x)
ByteBufferWrites two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two.
putChar in class DirectByteBuffer
public ByteBuffer putChar(int i,
char x)
ByteBufferWrites two bytes containing the given char value, in the current byte order, into this buffer at the given index.
putChar in class DirectByteBufferpublic CharBuffer asCharBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asCharBuffer in class DirectByteBuffer
private ByteBuffer putShort(long a,
short x)
public ByteBuffer putShort(short x)
ByteBufferWrites two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two.
putShort in class DirectByteBuffer
public ByteBuffer putShort(int i,
short x)
ByteBufferWrites two bytes containing the given short value, in the current byte order, into this buffer at the given index.
putShort in class DirectByteBufferpublic ShortBuffer asShortBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asShortBuffer in class DirectByteBuffer
private ByteBuffer putInt(long a,
int x)
public ByteBuffer putInt(int x)
ByteBufferWrites four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.
putInt in class DirectByteBuffer
public ByteBuffer putInt(int i,
int x)
ByteBufferWrites four bytes containing the given int value, in the current byte order, into this buffer at the given index.
putInt in class DirectByteBufferpublic IntBuffer asIntBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asIntBuffer in class DirectByteBuffer
private ByteBuffer putLong(long a,
long x)
public ByteBuffer putLong(long x)
ByteBufferWrites eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
putLong in class DirectByteBuffer
public ByteBuffer putLong(int i,
long x)
ByteBufferWrites eight bytes containing the given long value, in the current byte order, into this buffer at the given index.
putLong in class DirectByteBufferpublic LongBuffer asLongBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asLongBuffer in class DirectByteBuffer
private ByteBuffer putFloat(long a,
float x)
public ByteBuffer putFloat(float x)
ByteBufferWrites four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four.
putFloat in class DirectByteBuffer
public ByteBuffer putFloat(int i,
float x)
ByteBufferWrites four bytes containing the given float value, in the current byte order, into this buffer at the given index.
putFloat in class DirectByteBufferpublic FloatBuffer asFloatBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asFloatBuffer in class DirectByteBuffer
private ByteBuffer putDouble(long a,
double x)
public ByteBuffer putDouble(double x)
ByteBufferWrites eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
putDouble in class DirectByteBuffer
public ByteBuffer putDouble(int i,
double x)
ByteBufferWrites eight bytes containing the given double value, in the current byte order, into this buffer at the given index.
putDouble in class DirectByteBufferpublic DoubleBuffer asDoubleBuffer()
ByteBufferThe content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
asDoubleBuffer in class DirectByteBufferpublic Object viewedBuffer()
viewedBuffer in interface sun.nio.ch.DirectBufferpublic sun.misc.Cleaner cleaner()
cleaner in interface sun.nio.ch.DirectBufferpublic long address()
address in interface sun.nio.ch.DirectBufferpublic byte get()
ByteBuffer
get in class ByteBufferpublic byte get(int i)
ByteBuffer
get in class ByteBufferi - The index from which the byte will be read
public ByteBuffer get(byte[] dst,
int offset,
int length)
ByteBuffer This method transfers bytes from this buffer into the given
destination array. If there are fewer bytes remaining in the
buffer than are required to satisfy the request, that is, if
length > remaining(), then no
bytes are transferred and a BufferUnderflowException is
thrown.
Otherwise, this method copies length bytes from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length.
In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop
for (int i = off; i < off + len; i++)
dst[i] = src.get();
except that it first checks that there are sufficient bytes in
this buffer and it is potentially much more efficient.
get in class ByteBufferdst - The array into which bytes are to be writtenoffset - The offset within the array of the first byte to be
written; must be non-negative and no larger than
dst.lengthlength - The maximum number of bytes to be written to the given
array; must be non-negative and no larger than
dst.length - offset
public char getChar()
ByteBufferReads the next two bytes at this buffer's current position, composing them into a char value according to the current byte order, and then increments the position by two.
getChar in class ByteBufferpublic char getChar(int i)
ByteBufferReads two bytes at the given index, composing them into a char value according to the current byte order.
getChar in class ByteBufferi - The index from which the bytes will be read
public short getShort()
ByteBufferReads the next two bytes at this buffer's current position, composing them into a short value according to the current byte order, and then increments the position by two.
getShort in class ByteBufferpublic short getShort(int i)
ByteBufferReads two bytes at the given index, composing them into a short value according to the current byte order.
getShort in class ByteBufferi - The index from which the bytes will be read
public int getInt()
ByteBufferReads the next four bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by four.
getInt in class ByteBufferpublic int getInt(int i)
ByteBufferReads four bytes at the given index, composing them into a int value according to the current byte order.
getInt in class ByteBufferi - The index from which the bytes will be read
public long getLong()
ByteBufferReads the next eight bytes at this buffer's current position, composing them into a long value according to the current byte order, and then increments the position by eight.
getLong in class ByteBufferpublic long getLong(int i)
ByteBufferReads eight bytes at the given index, composing them into a long value according to the current byte order.
getLong in class ByteBufferi - The index from which the bytes will be read
public float getFloat()
ByteBufferReads the next four bytes at this buffer's current position, composing them into a float value according to the current byte order, and then increments the position by four.
getFloat in class ByteBufferpublic float getFloat(int i)
ByteBufferReads four bytes at the given index, composing them into a float value according to the current byte order.
getFloat in class ByteBufferi - The index from which the bytes will be read
public double getDouble()
ByteBufferReads the next eight bytes at this buffer's current position, composing them into a double value according to the current byte order, and then increments the position by eight.
getDouble in class ByteBufferpublic double getDouble(int i)
ByteBufferReads eight bytes at the given index, composing them into a double value according to the current byte order.
getDouble in class ByteBufferi - The index from which the bytes will be read
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||