public class GenericNioBuffer
extends java.lang.Object
Constructor and Description |
---|
GenericNioBuffer(java.nio.Buffer buf)
Construct a GenericNioBuffer based on an existing
Buffer . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
array()
Returns the primitive array that backs this buffer
(optional operation).
|
int |
arrayOffset()
Returns the offset within this buffer's backing array of the first
element of the buffer (optional operation).
|
java.nio.Buffer |
duplicate()
Creates a new buffer that shares this buffer's content.
|
void |
get(java.lang.Object dst)
Generic relative bulk get method.
|
void |
get(java.lang.Object dst,
int offset,
int length)
Generic relative bulk get method.
|
java.nio.Buffer |
getBuffer()
Returns the buffer object on which this generic buffer is based.
|
java.lang.Class<?> |
getElementClass()
Returns the class object of the primitive type that the buffer
holds.
|
boolean |
hasArray()
Tells whether or not this buffer is backed by an accessible
primitive array.
|
void |
put(java.lang.Object src)
Generic relative bulk put method.
|
void |
put(java.lang.Object src,
int offset,
int length)
Generic relative bulk put method.
|
public GenericNioBuffer(java.nio.Buffer buf)
Buffer
.buf
- the NIO bufferpublic java.nio.Buffer getBuffer()
public void get(java.lang.Object dst)
dst
- an array of primitives matching the type of the
nio BufferDoubleBuffer.get(double[])
public void get(java.lang.Object dst, int offset, int length)
dst
- an array of primitives matching the type of the
nio Bufferoffset
- the offset within the array of the first primitive
to be writtenlength
- the number of primitives to be transferredDoubleBuffer.get(double[],int,int)
public void put(java.lang.Object src)
src
- an array of primitives matching the type of the
nio BufferDoubleBuffer.put(double[])
public void put(java.lang.Object src, int offset, int length)
src
- an array of primitives matching the type of the
nio Bufferoffset
- the offset within the array of the first primitive
to be readlength
- the number of primitives to tranferDoubleBuffer.put(double[],int,int)
public java.nio.Buffer duplicate()
The 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.
DoubleBuffer.duplicate()
public boolean hasArray()
array()
and arrayOffset()
methods may safely be
invoked.DoubleBuffer.hasArray()
public java.lang.Object array()
Invoke the hasArray()
method before invoking this method in
order to ensure that this buffer has an accessible backing array.
java.nio.ReadOnlyBufferException
- if this buffer is backed by an
array but is read-onlyjava.lang.UnsupportedOperationException
- if this buffer is not backed
by an accessible arraypublic int arrayOffset()
Invoke the hasArray()
method before invoking this method in
order to ensure that this buffer has an accessible backing array.
java.nio.ReadOnlyBufferException
- if this buffer is backed by an
array but is read-onlyjava.lang.UnsupportedOperationException
- if this buffer is not backed
by an accessible arraypublic java.lang.Class<?> getElementClass()
double.class
is returned if the base buffer
is a DoubleBuffer
etc.