org.apache.mina.common

Class ByteBufferProxy

Implemented Interfaces:
Comparable

public class ByteBufferProxy
extends ByteBuffer

A ByteBuffer that wraps a buffer and proxies any operations to it.

You can think this class like a FilterOutputStream. All operations are proxied by default so that you can extend this class and override existing operations selectively. You can introduce new operations, too.

Field Summary

protected ByteBuffer
buf
The buffer proxied by this proxy.

Constructor Summary

ByteBufferProxy(ByteBuffer buf)
Create a new instance.

Method Summary

void
acquire()
Increases the internal reference count of this buffer to defer automatic release.
byte[]
array()
int
arrayOffset()
CharBuffer
asCharBuffer()
DoubleBuffer
asDoubleBuffer()
FloatBuffer
asFloatBuffer()
InputStream
asInputStream()
Returns an InputStream that reads the data from this buffer.
IntBuffer
asIntBuffer()
LongBuffer
asLongBuffer()
OutputStream
asOutputStream()
Returns an OutputStream that appends the data into this buffer.
ByteBuffer
asReadOnlyBuffer()
ShortBuffer
asShortBuffer()
java.nio.ByteBuffer
buf()
Returns the underlying NIO buffer instance.
int
capacity()
ByteBuffer
capacity(int newCapacity)
Changes the capacity of this buffer.
ByteBuffer
clear()
ByteBuffer
compact()
int
compareTo(ByteBuffer that)
ByteBuffer
duplicate()
boolean
equals(Object ob)
ByteBuffer
expand(int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the current position.
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.
ByteBuffer
fill(byte value, int size)
Fills this buffer with the specified value.
ByteBuffer
fill(int size)
Fills this buffer with NUL (0x00).
ByteBuffer
fillAndReset(byte value, int size)
Fills this buffer with the specified value.
ByteBuffer
fillAndReset(int size)
Fills this buffer with NUL (0x00).
ByteBuffer
flip()
byte
get()
ByteBuffer
get(byte[] dst)
ByteBuffer
get(byte[] dst, int offset, int length)
byte
get(int index)
char
getChar()
char
getChar(int index)
double
getDouble()
double
getDouble(int index)
float
getFloat()
float
getFloat(int index)
String
getHexDump()
Returns hexdump of this buffer.
int
getInt()
int
getInt(int index)
long
getLong()
long
getLong(int index)
Object
getObject()
Reads a Java object from the buffer using the context ClassLoader of the current thread.
Object
getObject(ClassLoader classLoader)
Reads a Java object from the buffer using the specified classLoader.
String
getPrefixedString(CharsetDecoder decoder)
Reads a string which has a 16-bit length field before the actual encoded string, using the specified decoder and returns it.
String
getPrefixedString(int prefixLength, CharsetDecoder decoder)
Reads a string which has a length field before the actual encoded string, using the specified decoder and returns it.
short
getShort()
short
getShort(int index)
String
getString(CharsetDecoder decoder)
Reads a NUL-terminated string from this buffer using the specified decoder and returns it.
String
getString(int fieldSize, CharsetDecoder decoder)
Reads a NUL-terminated string from this buffer using the specified decoder and returns it.
short
getUnsigned()
Reads one unsigned byte as a short integer.
short
getUnsigned(int index)
Reads one byte as an unsigned short integer.
long
getUnsignedInt()
Reads four bytes unsigned integer.
long
getUnsignedInt(int index)
Reads four bytes unsigned integer.
int
getUnsignedShort()
Reads two bytes unsigned integer.
int
getUnsignedShort(int index)
Reads two bytes unsigned integer.
boolean
hasRemaining()
int
hashCode()
boolean
isAutoExpand()
Returns true if and only if autoExpand is turned on.
boolean
isDirect()
boolean
isPooled()
Returns true if and only if this buffer is returned back to the buffer pool when released.
boolean
isReadOnly()
int
limit()
ByteBuffer
limit(int newLimit)
ByteBuffer
mark()
int
markValue()
Returns the position of the current mark.
ByteOrder
order()
ByteBuffer
order(ByteOrder bo)
int
position()
ByteBuffer
position(int newPosition)
ByteBuffer
put(byte b)
ByteBuffer
put(byte[] src)
ByteBuffer
put(byte[] src, int offset, int length)
ByteBuffer
put(int index, byte b)
ByteBuffer
put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
ByteBuffer
put(ByteBuffer src)
Writes the content of the specified src into this buffer.
ByteBuffer
putChar(char value)
ByteBuffer
putChar(int index, char value)
ByteBuffer
putDouble(double value)
ByteBuffer
putDouble(int index, double value)
ByteBuffer
putFloat(float value)
ByteBuffer
putFloat(int index, float value)
ByteBuffer
putInt(int value)
ByteBuffer
putInt(int index, int value)
ByteBuffer
putLong(int index, long value)
ByteBuffer
putLong(long value)
ByteBuffer
putObject(Object o)
Writes the specified Java object to the buffer.
ByteBuffer
putPrefixedString(CharSequence in, CharsetEncoder encoder)
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.
ByteBuffer
putPrefixedString(CharSequence in, int prefixLength, CharsetEncoder encoder)
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.
ByteBuffer
putPrefixedString(CharSequence in, int prefixLength, int padding, CharsetEncoder encoder)
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.
ByteBuffer
putPrefixedString(CharSequence in, int prefixLength, int padding, byte padValue, CharsetEncoder encoder)
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.
ByteBuffer
putShort(int index, short value)
ByteBuffer
putShort(short value)
ByteBuffer
putString(CharSequence in, CharsetEncoder encoder)
Writes the content of in into this buffer using the specified encoder.
ByteBuffer
putString(CharSequence in, int fieldSize, CharsetEncoder encoder)
Writes the content of in into this buffer as a NUL-terminated string using the specified encoder.
void
release()
Releases the specified buffer to buffer pool.
int
remaining()
ByteBuffer
reset()
ByteBuffer
rewind()
ByteBuffer
setAutoExpand(boolean autoExpand)
Turns on or off autoExpand.
void
setPooled(boolean pooled)
Sets whether this buffer is returned back to the buffer pool when released.
ByteBuffer
skip(int size)
Forwards the position of this buffer as the specified size bytes.
ByteBuffer
slice()
ByteBuffer
sweep()
Clears this buffer and fills its content with NUL.
ByteBuffer
sweep(byte value)
Clears this buffer and fills its content with value.
String
toString()

Methods inherited from class org.apache.mina.common.ByteBuffer

String toString, acquire, allocate, allocate, array, arrayOffset, asCharBuffer, asDoubleBuffer, asFloatBuffer, asInputStream, asIntBuffer, asLongBuffer, asOutputStream, asReadOnlyBuffer, asShortBuffer, autoExpand, autoExpand, boolean equals, buf, capacity, capacity, clear, compact, compareTo, duplicate, expand, expand, fill, fill, fillAndReset, fillAndReset, flip, get, get, get, get, getAllocator, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getHexDump, getInt, getInt, getLong, getLong, getObject, getObject, getPrefixedString, getPrefixedString, getShort, getShort, getString, getString, getUnsigned, getUnsigned, getUnsignedInt, getUnsignedInt, getUnsignedShort, getUnsignedShort, hasRemaining, int hashCode, isAutoExpand, isDirect, isPooled, isReadOnly, isUseDirectBuffers, limit, limit, mark, markValue, order, order, position, position, prefixedDataAvailable, prefixedDataAvailable, put, put, put, put, put, put, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putObject, putPrefixedString, putPrefixedString, putPrefixedString, putPrefixedString, putShort, putShort, putString, putString, release, remaining, reset, rewind, setAllocator, setAutoExpand, setPooled, setUseDirectBuffers, skip, slice, sweep, sweep, wrap, wrap, wrap

Field Details

buf

protected ByteBuffer buf
The buffer proxied by this proxy.

Constructor Details

ByteBufferProxy

protected ByteBufferProxy(ByteBuffer buf)
Create a new instance.
Parameters:
buf - the buffer to be proxied

Method Details

acquire

public void acquire()
Overrides:
acquire in interface ByteBuffer

array

public byte[] array()
Overrides:
array in interface ByteBuffer
See Also:
java.nio.ByteBuffer.array()

arrayOffset

public int arrayOffset()
Overrides:
arrayOffset in interface ByteBuffer
See Also:
java.nio.ByteBuffer.arrayOffset()

asCharBuffer

public CharBuffer asCharBuffer()
Overrides:
asCharBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asCharBuffer()

asDoubleBuffer

public DoubleBuffer asDoubleBuffer()
Overrides:
asDoubleBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asDoubleBuffer()

asFloatBuffer

public FloatBuffer asFloatBuffer()
Overrides:
asFloatBuffer in interface ByteBuffer
See Also:
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.
Overrides:
asInputStream in interface ByteBuffer

asIntBuffer

public IntBuffer asIntBuffer()
Overrides:
asIntBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asIntBuffer()

asLongBuffer

public LongBuffer asLongBuffer()
Overrides:
asLongBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asLongBuffer()

asOutputStream

public OutputStream asOutputStream()
Overrides:
asOutputStream in interface ByteBuffer

asReadOnlyBuffer

public ByteBuffer asReadOnlyBuffer()
Overrides:
asReadOnlyBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asReadOnlyBuffer()

asShortBuffer

public ShortBuffer asShortBuffer()
Overrides:
asShortBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asShortBuffer()

buf

public java.nio.ByteBuffer buf()
Returns the underlying NIO buffer instance.
Overrides:
buf in interface ByteBuffer

capacity

public int capacity()
Overrides:
capacity in interface ByteBuffer
See Also:
java.nio.ByteBuffer.capacity()

capacity

public ByteBuffer capacity(int newCapacity)
Changes the capacity of this buffer.
Overrides:
capacity in interface ByteBuffer

clear

public ByteBuffer clear()
Overrides:
clear in interface ByteBuffer
See Also:
java.nio.Buffer.clear()

compact

public ByteBuffer compact()
Overrides:
compact in interface ByteBuffer
See Also:
java.nio.ByteBuffer.compact()

compareTo

public int compareTo(ByteBuffer that)
Overrides:
compareTo in interface ByteBuffer

duplicate

public ByteBuffer duplicate()
Overrides:
duplicate in interface ByteBuffer
See Also:
java.nio.ByteBuffer.duplicate()

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.
Overrides:
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.
Overrides:
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.
Overrides:
fill in interface ByteBuffer

fill

public ByteBuffer fill(int size)
Fills this buffer with NUL (0x00). This method moves buffer position forward.
Overrides:
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.
Overrides:
fillAndReset in interface ByteBuffer

fillAndReset

public ByteBuffer fillAndReset(int size)
Fills this buffer with NUL (0x00). This method does not change buffer position.
Overrides:
fillAndReset in interface ByteBuffer

flip

public ByteBuffer flip()
Overrides:
flip in interface ByteBuffer
See Also:
java.nio.Buffer.flip()

get

public byte get()
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get()

get

public ByteBuffer get(byte[] dst)
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get(byte[])

get

public ByteBuffer get(byte[] dst,
                      int offset,
                      int length)
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get(byte[], int, int)

get

public byte get(int index)
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get(int)

getChar

public char getChar()
Overrides:
getChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getChar()

getChar

public char getChar(int index)
Overrides:
getChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getChar(int)

getDouble

public double getDouble()
Overrides:
getDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getDouble()

getDouble

public double getDouble(int index)
Overrides:
getDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getDouble(int)

getFloat

public float getFloat()
Overrides:
getFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getFloat()

getFloat

public float getFloat(int index)
Overrides:
getFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getFloat(int)

getHexDump

public String getHexDump()
Returns hexdump of this buffer.
Overrides:
getHexDump in interface ByteBuffer

getInt

public int getInt()
Overrides:
getInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getInt()

getInt

public int getInt(int index)
Overrides:
getInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getInt(int)

getLong

public long getLong()
Overrides:
getLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getLong()

getLong

public long getLong(int index)
Overrides:
getLong in interface ByteBuffer
See Also:
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.
Overrides:
getObject in interface ByteBuffer

getObject

public Object getObject(ClassLoader classLoader)
            throws ClassNotFoundException
Reads a Java object from the buffer using the specified classLoader.
Overrides:
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).
Overrides:
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.
Overrides:
getPrefixedString in interface ByteBuffer
Parameters:
prefixLength - the length of the length field (1, 2, or 4)

getShort

public short getShort()
Overrides:
getShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getShort()

getShort

public short getShort(int index)
Overrides:
getShort in interface ByteBuffer
See Also:
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.
Overrides:
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.
Overrides:
getString in interface ByteBuffer
Parameters:
fieldSize - the maximum number of bytes to read

getUnsigned

public short getUnsigned()
Reads one unsigned byte as a short integer.
Overrides:
getUnsigned in interface ByteBuffer

getUnsigned

public short getUnsigned(int index)
Reads one byte as an unsigned short integer.
Overrides:
getUnsigned in interface ByteBuffer

getUnsignedInt

public long getUnsignedInt()
Reads four bytes unsigned integer.
Overrides:
getUnsignedInt in interface ByteBuffer

getUnsignedInt

public long getUnsignedInt(int index)
Reads four bytes unsigned integer.
Overrides:
getUnsignedInt in interface ByteBuffer

getUnsignedShort

public int getUnsignedShort()
Reads two bytes unsigned integer.
Overrides:
getUnsignedShort in interface ByteBuffer

getUnsignedShort

public int getUnsignedShort(int index)
Reads two bytes unsigned integer.
Overrides:
getUnsignedShort in interface ByteBuffer

hasRemaining

public boolean hasRemaining()
Overrides:
hasRemaining in interface ByteBuffer
See Also:
java.nio.Buffer.hasRemaining()

hashCode

public int hashCode()

isAutoExpand

public boolean isAutoExpand()
Returns true if and only if autoExpand is turned on.
Overrides:
isAutoExpand in interface ByteBuffer

isDirect

public boolean isDirect()
Overrides:
isDirect in interface ByteBuffer
See Also:
java.nio.ByteBuffer.isDirect()

isPooled

public boolean isPooled()
Overrides:
isPooled in interface ByteBuffer

isReadOnly

public boolean isReadOnly()
Overrides:
isReadOnly in interface ByteBuffer
See Also:
java.nio.ByteBuffer.isReadOnly()

limit

public int limit()
Overrides:
limit in interface ByteBuffer
See Also:
java.nio.Buffer.limit()

limit

public ByteBuffer limit(int newLimit)
Overrides:
limit in interface ByteBuffer
See Also:
java.nio.Buffer.limit(int)

mark

public ByteBuffer mark()
Overrides:
mark in interface ByteBuffer
See Also:
java.nio.Buffer.mark()

markValue

public int markValue()
Returns the position of the current mark. This method returns -1 if no mark is set.
Overrides:
markValue in interface ByteBuffer

order

public ByteOrder order()
Overrides:
order in interface ByteBuffer
See Also:
java.nio.ByteBuffer.order()

order

public ByteBuffer order(ByteOrder bo)
Overrides:
order in interface ByteBuffer
See Also:
java.nio.ByteBuffer.order(ByteOrder)

position

public int position()
Overrides:
position in interface ByteBuffer
See Also:
java.nio.Buffer.position()

position

public ByteBuffer position(int newPosition)
Overrides:
position in interface ByteBuffer
See Also:
java.nio.Buffer.position(int)

put

public ByteBuffer put(byte b)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(byte)

put

public ByteBuffer put(byte[] src)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(byte[])

put

public ByteBuffer put(byte[] src,
                      int offset,
                      int length)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(byte[], int, int)

put

public ByteBuffer put(int index,
                      byte b)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(int, byte)

put

public ByteBuffer put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
Overrides:
put in interface ByteBuffer

put

public ByteBuffer put(ByteBuffer src)
Writes the content of the specified src into this buffer.
Overrides:
put in interface ByteBuffer

putChar

public ByteBuffer putChar(char value)
Overrides:
putChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putChar(char)

putChar

public ByteBuffer putChar(int index,
                          char value)
Overrides:
putChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putChar(int, char)

putDouble

public ByteBuffer putDouble(double value)
Overrides:
putDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putDouble(double)

putDouble

public ByteBuffer putDouble(int index,
                            double value)
Overrides:
putDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putDouble(int, double)

putFloat

public ByteBuffer putFloat(float value)
Overrides:
putFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putFloat(float)

putFloat

public ByteBuffer putFloat(int index,
                           float value)
Overrides:
putFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putFloat(int, float)

putInt

public ByteBuffer putInt(int value)
Overrides:
putInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putInt(int)

putInt

public ByteBuffer putInt(int index,
                         int value)
Overrides:
putInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putInt(int, int)

putLong

public ByteBuffer putLong(int index,
                          long value)
Overrides:
putLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putLong(int, long)

putLong

public ByteBuffer putLong(long value)
Overrides:
putLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putLong(int, long)

putObject

public ByteBuffer putObject(Object o)
Writes the specified Java object to the buffer.
Overrides:
putObject 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).
Overrides:
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).
Overrides:
putPrefixedString in interface ByteBuffer
Parameters:
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).
Overrides:
putPrefixedString in interface ByteBuffer
Parameters:
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.
Overrides:
putPrefixedString in interface ByteBuffer
Parameters:
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

putShort

public ByteBuffer putShort(int index,
                           short value)
Overrides:
putShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putShort(int, short)

putShort

public ByteBuffer putShort(short value)
Overrides:
putShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putShort(short)

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.
Overrides:
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 NULs as a terminator.

Please note that this method doesn't terminate with NUL if the input string is longer than fieldSize.

Overrides:
putString in interface ByteBuffer
Parameters:
fieldSize - the maximum number of bytes to write

release

public void release()
Releases the specified buffer to buffer pool.
Overrides:
release in interface ByteBuffer

remaining

public int remaining()
Overrides:
remaining in interface ByteBuffer
See Also:
java.nio.Buffer.remaining()

reset

public ByteBuffer reset()
Overrides:
reset in interface ByteBuffer
See Also:
java.nio.Buffer.reset()

rewind

public ByteBuffer rewind()
Overrides:
rewind in interface ByteBuffer
See Also:
java.nio.Buffer.rewind()

setAutoExpand

public ByteBuffer setAutoExpand(boolean autoExpand)
Turns on or off autoExpand.
Overrides:
setAutoExpand in interface ByteBuffer

setPooled

public void setPooled(boolean pooled)
Overrides:
setPooled in interface ByteBuffer

skip

public ByteBuffer skip(int size)
Forwards the position of this buffer as the specified size bytes.
Overrides:
skip in interface ByteBuffer

slice

public ByteBuffer slice()
Overrides:
slice in interface ByteBuffer
See Also:
java.nio.ByteBuffer.slice()

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.
Overrides:
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.
Overrides:
sweep in interface ByteBuffer

toString

public String toString()