acquire
public void acquire()
Increases the internal reference count of this buffer to defer
automatic release. You have to invoke
ByteBuffer.release()
as many
as you invoked this method to release this buffer.
- acquire in interface ByteBuffer
array
public byte[] array()
- array in interface ByteBuffer
java.nio.ByteBuffer.array()
asCharBuffer
public CharBuffer asCharBuffer()
- asCharBuffer in interface ByteBuffer
java.nio.ByteBuffer.asCharBuffer()
asDoubleBuffer
public DoubleBuffer asDoubleBuffer()
- asDoubleBuffer in interface ByteBuffer
java.nio.ByteBuffer.asDoubleBuffer()
asFloatBuffer
public FloatBuffer asFloatBuffer()
- asFloatBuffer in interface ByteBuffer
java.nio.ByteBuffer.asFloatBuffer()
asInputStream
public InputStream asInputStream()
Returns an InputStream
that reads the data from this buffer.
InputStream.read()
returns -1 if the buffer position
reaches to the limit.
- asInputStream in interface ByteBuffer
asIntBuffer
public IntBuffer asIntBuffer()
- asIntBuffer in interface ByteBuffer
java.nio.ByteBuffer.asIntBuffer()
asLongBuffer
public LongBuffer asLongBuffer()
- asLongBuffer in interface ByteBuffer
java.nio.ByteBuffer.asLongBuffer()
asOutputStream
public OutputStream asOutputStream()
Returns an
OutputStream
that appends the data into this buffer.
Please note that the
OutputStream.write(int)
will throw a
BufferOverflowException
instead of an
IOException
in case of buffer overflow. Please set
autoExpand property by
calling
ByteBuffer.setAutoExpand(boolean)
to prevent the unexpected runtime
exception.
- asOutputStream in interface ByteBuffer
asShortBuffer
public ShortBuffer asShortBuffer()
- asShortBuffer in interface ByteBuffer
java.nio.ByteBuffer.asShortBuffer()
buf
public java.nio.ByteBuffer buf()
Returns the underlying NIO buffer instance.
- buf in interface ByteBuffer
capacity
public int capacity()
- capacity in interface ByteBuffer
java.nio.ByteBuffer.capacity()
equals
public boolean equals(Object ob)
expand
public ByteBuffer expand(int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the current position.
This method works even if you didn't set autoExpand to
true.
- expand in interface ByteBuffer
expand
public ByteBuffer expand(int pos,
int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the specified
pos.
This method works even if you didn't set autoExpand to
true.
- expand in interface ByteBuffer
fill
public ByteBuffer fill(byte value,
int size)
Fills this buffer with the specified value.
This method moves buffer position forward.
- fill in interface ByteBuffer
fill
public ByteBuffer fill(int size)
Fills this buffer with NUL (0x00)
.
This method moves buffer position forward.
- fill in interface ByteBuffer
fillAndReset
public ByteBuffer fillAndReset(byte value,
int size)
Fills this buffer with the specified value.
This method does not change buffer position.
- fillAndReset in interface ByteBuffer
fillAndReset
public ByteBuffer fillAndReset(int size)
Fills this buffer with NUL (0x00)
.
This method does not change buffer position.
- fillAndReset in interface ByteBuffer
get
public byte get()
- get in interface ByteBuffer
java.nio.ByteBuffer.get()
get
public ByteBuffer get(byte[] dst,
int offset,
int length)
- get in interface ByteBuffer
java.nio.ByteBuffer.get(byte[], int, int)
get
public byte get(int index)
- get in interface ByteBuffer
java.nio.ByteBuffer.get(int)
getChar
public char getChar()
- getChar in interface ByteBuffer
java.nio.ByteBuffer.getChar()
getChar
public char getChar(int index)
- getChar in interface ByteBuffer
java.nio.ByteBuffer.getChar(int)
getDouble
public double getDouble()
- getDouble in interface ByteBuffer
java.nio.ByteBuffer.getDouble()
getDouble
public double getDouble(int index)
- getDouble in interface ByteBuffer
java.nio.ByteBuffer.getDouble(int)
getFloat
public float getFloat()
- getFloat in interface ByteBuffer
java.nio.ByteBuffer.getFloat()
getFloat
public float getFloat(int index)
- getFloat in interface ByteBuffer
java.nio.ByteBuffer.getFloat(int)
getHexDump
public String getHexDump()
Returns hexdump of this buffer.
- getHexDump in interface ByteBuffer
getInt
public int getInt()
- getInt in interface ByteBuffer
java.nio.ByteBuffer.getInt()
getInt
public int getInt(int index)
- getInt in interface ByteBuffer
java.nio.ByteBuffer.getInt(int)
getLong
public long getLong()
- getLong in interface ByteBuffer
java.nio.ByteBuffer.getLong()
getLong
public long getLong(int index)
- getLong in interface ByteBuffer
java.nio.ByteBuffer.getLong(int)
getObject
public Object getObject()
throws ClassNotFoundException
Reads a Java object from the buffer using the context ClassLoader
of the current thread.
- getObject in interface ByteBuffer
getObject
public Object getObject(ClassLoader classLoader)
throws ClassNotFoundException
Reads a Java object from the buffer using the specified classLoader.
- getObject in interface ByteBuffer
getPrefixedString
public String getPrefixedString(CharsetDecoder decoder)
throws CharacterCodingException
Reads a string which has a 16-bit length field before the actual
encoded string, using the specified decoder
and returns it.
This method is a shortcut for getPrefixedString(2, decoder).
- getPrefixedString in interface ByteBuffer
getPrefixedString
public String getPrefixedString(int prefixLength,
CharsetDecoder decoder)
throws CharacterCodingException
Reads a string which has a length field before the actual
encoded string, using the specified decoder
and returns it.
- getPrefixedString in interface ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)
getShort
public short getShort()
- getShort in interface ByteBuffer
java.nio.ByteBuffer.getShort()
getShort
public short getShort(int index)
- getShort in interface ByteBuffer
java.nio.ByteBuffer.getShort()
getString
public String getString(CharsetDecoder decoder)
throws CharacterCodingException
Reads a NUL
-terminated string from this buffer using the
specified decoder
and returns it. This method reads
until the limit of this buffer if no NUL is found.
- getString in interface ByteBuffer
getString
public String getString(int fieldSize,
CharsetDecoder decoder)
throws CharacterCodingException
Reads a NUL
-terminated string from this buffer using the
specified decoder
and returns it.
- getString in interface ByteBuffer
fieldSize
- the maximum number of bytes to read
getUnsigned
public short getUnsigned()
Reads one unsigned byte as a short integer.
- getUnsigned in interface ByteBuffer
getUnsigned
public short getUnsigned(int index)
Reads one byte as an unsigned short integer.
- getUnsigned in interface ByteBuffer
getUnsignedInt
public long getUnsignedInt(int index)
Reads four bytes unsigned integer.
- getUnsignedInt in interface ByteBuffer
hashCode
public int hashCode()
isAutoExpand
public boolean isAutoExpand()
Returns true if and only if autoExpand is turned on.
- isAutoExpand in interface ByteBuffer
isDirect
public boolean isDirect()
- isDirect in interface ByteBuffer
java.nio.ByteBuffer.isDirect()
isReadOnly
public boolean isReadOnly()
- isReadOnly in interface ByteBuffer
java.nio.ByteBuffer.isReadOnly()
markValue
public int markValue()
Returns the position of the current mark. This method returns -1 if no
mark is set.
- markValue in interface ByteBuffer
order
public ByteOrder order()
- order in interface ByteBuffer
java.nio.ByteBuffer.order()
put
public ByteBuffer put(byte[] src,
int offset,
int length)
- put in interface ByteBuffer
java.nio.ByteBuffer.put(byte[], int, int)
put
public ByteBuffer put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
- put in interface ByteBuffer
putPrefixedString
public ByteBuffer putPrefixedString(CharSequence in,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, 2, 0, encoder).
- putPrefixedString in interface ByteBuffer
putPrefixedString
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, prefixLength, 0, encoder).
- putPrefixedString in interface ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)
putPrefixedString
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
int padding,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, prefixLength, padding, ( byte ) 0, encoder).
- putPrefixedString in interface ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)padding
- the number of padded NULs (1 (or 0), 2, or 4)
putPrefixedString
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
int padding,
byte padValue,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
- putPrefixedString in interface ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)padding
- the number of padded bytes (1 (or 0), 2, or 4)padValue
- the value of padded bytes
putString
public ByteBuffer putString(CharSequence in,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of in
into this buffer using the
specified encoder
. This method doesn't terminate
string with NUL. You have to do it by yourself.
- putString in interface ByteBuffer
putString
public ByteBuffer putString(CharSequence in,
int fieldSize,
CharsetEncoder encoder)
throws CharacterCodingException
Writes the content of
in
into this buffer as a
NUL
-terminated string using the specified
encoder
.
If the charset name of the encoder is UTF-16, you cannot specify
odd
fieldSize
, and this method will append two
NUL
s as a terminator.
Please note that this method doesn't terminate with
NUL
if the input string is longer than
fieldSize.
- putString in interface ByteBuffer
fieldSize
- the maximum number of bytes to write
release
public void release()
Releases the specified buffer to buffer pool.
- release in interface ByteBuffer
skip
public ByteBuffer skip(int size)
Forwards the position of this buffer as the specified size
bytes.
- skip in interface ByteBuffer
sweep
public ByteBuffer sweep()
Clears this buffer and fills its content with NUL.
The position is set to zero, the limit is set to the capacity,
and the mark is discarded.
- sweep in interface ByteBuffer
sweep
public ByteBuffer sweep(byte value)
Clears this buffer and fills its content with value.
The position is set to zero, the limit is set to the capacity,
and the mark is discarded.
- sweep in interface ByteBuffer
toString
public String toString()