org.apache.mina.common
Class ByteBufferProxy

java.lang.Object
  extended by org.apache.mina.common.ByteBuffer
      extended by org.apache.mina.common.ByteBufferProxy
All Implemented Interfaces:
Comparable<ByteBuffer>

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.

Version:
$Rev: 555855 $, $Date: 2007-07-13 05:19:00 +0200 (Fr, 13. Jul 2007) $
Author:
The Apache Directory Project (mina-dev@directory.apache.org)

Field Summary
protected  ByteBuffer buf
          The buffer proxied by this proxy.
 
Constructor Summary
protected 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()
           
 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.
 int hashCode()
           
 boolean hasRemaining()
           
 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(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 put(int index, byte b)
           
 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, 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 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 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
allocate, allocate, autoExpand, autoExpand, getAllocator, isUseDirectBuffers, prefixedDataAvailable, prefixedDataAvailable, setAllocator, setUseDirectBuffers, wrap, wrap, wrap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

buf

protected ByteBuffer buf
The buffer proxied by this proxy.

Constructor Detail

ByteBufferProxy

protected ByteBufferProxy(ByteBuffer buf)
Create a new instance.

Parameters:
buf - the buffer to be proxied
Method Detail

acquire

public void acquire()
Description copied from class: ByteBuffer
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.

Specified by:
acquire in class ByteBuffer

release

public void release()
Description copied from class: ByteBuffer
Releases the specified buffer to buffer pool.

Specified by:
release in class ByteBuffer

isDirect

public boolean isDirect()
Specified by:
isDirect in class ByteBuffer
See Also:
ByteBuffer.isDirect()

buf

public ByteBuffer buf()
Description copied from class: ByteBuffer
Returns the underlying NIO buffer instance.

Specified by:
buf in class ByteBuffer

capacity

public int capacity()
Specified by:
capacity in class ByteBuffer
See Also:
Buffer.capacity()

position

public int position()
Specified by:
position in class ByteBuffer
See Also:
Buffer.position()

position

public ByteBuffer position(int newPosition)
Specified by:
position in class ByteBuffer
See Also:
Buffer.position(int)

limit

public int limit()
Specified by:
limit in class ByteBuffer
See Also:
Buffer.limit()

limit

public ByteBuffer limit(int newLimit)
Specified by:
limit in class ByteBuffer
See Also:
Buffer.limit(int)

mark

public ByteBuffer mark()
Specified by:
mark in class ByteBuffer
See Also:
Buffer.mark()

reset

public ByteBuffer reset()
Specified by:
reset in class ByteBuffer
See Also:
Buffer.reset()

clear

public ByteBuffer clear()
Specified by:
clear in class ByteBuffer
See Also:
Buffer.clear()

sweep

public ByteBuffer sweep()
Description copied from class: ByteBuffer
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 class ByteBuffer

sweep

public ByteBuffer sweep(byte value)
Description copied from class: ByteBuffer
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 class ByteBuffer

flip

public ByteBuffer flip()
Specified by:
flip in class ByteBuffer
See Also:
Buffer.flip()

rewind

public ByteBuffer rewind()
Specified by:
rewind in class ByteBuffer
See Also:
Buffer.rewind()

remaining

public int remaining()
Overrides:
remaining in class ByteBuffer
See Also:
Buffer.remaining()

hasRemaining

public boolean hasRemaining()
Overrides:
hasRemaining in class ByteBuffer
See Also:
Buffer.hasRemaining()

get

public byte get()
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get()

getUnsigned

public short getUnsigned()
Description copied from class: ByteBuffer
Reads one unsigned byte as a short integer.

Overrides:
getUnsigned in class ByteBuffer

put

public ByteBuffer put(byte b)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(byte)

get

public byte get(int index)
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get(int)

getUnsigned

public short getUnsigned(int index)
Description copied from class: ByteBuffer
Reads one byte as an unsigned short integer.

Overrides:
getUnsigned in class ByteBuffer

put

public ByteBuffer put(int index,
                      byte b)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(int, byte)

get

public ByteBuffer get(byte[] dst,
                      int offset,
                      int length)
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get(byte[], int, int)

get

public ByteBuffer get(byte[] dst)
Overrides:
get in class ByteBuffer
See Also:
ByteBuffer.get(byte[])

put

public ByteBuffer put(ByteBuffer src)
Description copied from class: ByteBuffer
Writes the content of the specified src into this buffer.

Overrides:
put in class ByteBuffer

put

public ByteBuffer put(ByteBuffer src)
Description copied from class: ByteBuffer
Writes the content of the specified src into this buffer.

Specified by:
put in class ByteBuffer

put

public ByteBuffer put(byte[] src,
                      int offset,
                      int length)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(byte[], int, int)

put

public ByteBuffer put(byte[] src)
Overrides:
put in class ByteBuffer
See Also:
ByteBuffer.put(byte[])

compact

public ByteBuffer compact()
Specified by:
compact in class ByteBuffer
See Also:
ByteBuffer.compact()

toString

public String toString()
Overrides:
toString in class ByteBuffer

hashCode

public int hashCode()
Overrides:
hashCode in class ByteBuffer

equals

public boolean equals(Object ob)
Overrides:
equals in class ByteBuffer

compareTo

public int compareTo(ByteBuffer that)
Specified by:
compareTo in interface Comparable<ByteBuffer>
Overrides:
compareTo in class ByteBuffer

order

public ByteOrder order()
Specified by:
order in class ByteBuffer
See Also:
ByteBuffer.order()

order

public ByteBuffer order(ByteOrder bo)
Specified by:
order in class ByteBuffer
See Also:
ByteBuffer.order(ByteOrder)

getChar

public char getChar()
Specified by:
getChar in class ByteBuffer
See Also:
ByteBuffer.getChar()

putChar

public ByteBuffer putChar(char value)
Specified by:
putChar in class ByteBuffer
See Also:
ByteBuffer.putChar(char)

getChar

public char getChar(int index)
Specified by:
getChar in class ByteBuffer
See Also:
ByteBuffer.getChar(int)

putChar

public ByteBuffer putChar(int index,
                          char value)
Specified by:
putChar in class ByteBuffer
See Also:
ByteBuffer.putChar(int, char)

asCharBuffer

public CharBuffer asCharBuffer()
Specified by:
asCharBuffer in class ByteBuffer
See Also:
ByteBuffer.asCharBuffer()

getShort

public short getShort()
Specified by:
getShort in class ByteBuffer
See Also:
ByteBuffer.getShort()

getUnsignedShort

public int getUnsignedShort()
Description copied from class: ByteBuffer
Reads two bytes unsigned integer.

Overrides:
getUnsignedShort in class ByteBuffer

putShort

public ByteBuffer putShort(short value)
Specified by:
putShort in class ByteBuffer
See Also:
ByteBuffer.putShort(short)

getShort

public short getShort(int index)
Specified by:
getShort in class ByteBuffer
See Also:
ByteBuffer.getShort()

getUnsignedShort

public int getUnsignedShort(int index)
Description copied from class: ByteBuffer
Reads two bytes unsigned integer.

Overrides:
getUnsignedShort in class ByteBuffer

putShort

public ByteBuffer putShort(int index,
                           short value)
Specified by:
putShort in class ByteBuffer
See Also:
ByteBuffer.putShort(int, short)

asShortBuffer

public ShortBuffer asShortBuffer()
Specified by:
asShortBuffer in class ByteBuffer
See Also:
ByteBuffer.asShortBuffer()

getInt

public int getInt()
Specified by:
getInt in class ByteBuffer
See Also:
ByteBuffer.getInt()

getUnsignedInt

public long getUnsignedInt()
Description copied from class: ByteBuffer
Reads four bytes unsigned integer.

Overrides:
getUnsignedInt in class ByteBuffer

putInt

public ByteBuffer putInt(int value)
Specified by:
putInt in class ByteBuffer
See Also:
ByteBuffer.putInt(int)

getInt

public int getInt(int index)
Specified by:
getInt in class ByteBuffer
See Also:
ByteBuffer.getInt(int)

getUnsignedInt

public long getUnsignedInt(int index)
Description copied from class: ByteBuffer
Reads four bytes unsigned integer.

Overrides:
getUnsignedInt in class ByteBuffer

putInt

public ByteBuffer putInt(int index,
                         int value)
Specified by:
putInt in class ByteBuffer
See Also:
ByteBuffer.putInt(int, int)

asIntBuffer

public IntBuffer asIntBuffer()
Specified by:
asIntBuffer in class ByteBuffer
See Also:
ByteBuffer.asIntBuffer()

getLong

public long getLong()
Specified by:
getLong in class ByteBuffer
See Also:
ByteBuffer.getLong()

putLong

public ByteBuffer putLong(long value)
Specified by:
putLong in class ByteBuffer
See Also:
ByteBuffer.putLong(int, long)

getLong

public long getLong(int index)
Specified by:
getLong in class ByteBuffer
See Also:
ByteBuffer.getLong(int)

putLong

public ByteBuffer putLong(int index,
                          long value)
Specified by:
putLong in class ByteBuffer
See Also:
ByteBuffer.putLong(int, long)

asLongBuffer

public LongBuffer asLongBuffer()
Specified by:
asLongBuffer in class ByteBuffer
See Also:
ByteBuffer.asLongBuffer()

getFloat

public float getFloat()
Specified by:
getFloat in class ByteBuffer
See Also:
ByteBuffer.getFloat()

putFloat

public ByteBuffer putFloat(float value)
Specified by:
putFloat in class ByteBuffer
See Also:
ByteBuffer.putFloat(float)

getFloat

public float getFloat(int index)
Specified by:
getFloat in class ByteBuffer
See Also:
ByteBuffer.getFloat(int)

putFloat

public ByteBuffer putFloat(int index,
                           float value)
Specified by:
putFloat in class ByteBuffer
See Also:
ByteBuffer.putFloat(int, float)

asFloatBuffer

public FloatBuffer asFloatBuffer()
Specified by:
asFloatBuffer in class ByteBuffer
See Also:
ByteBuffer.asFloatBuffer()

getDouble

public double getDouble()
Specified by:
getDouble in class ByteBuffer
See Also:
ByteBuffer.getDouble()

putDouble

public ByteBuffer putDouble(double value)
Specified by:
putDouble in class ByteBuffer
See Also:
ByteBuffer.putDouble(double)

getDouble

public double getDouble(int index)
Specified by:
getDouble in class ByteBuffer
See Also:
ByteBuffer.getDouble(int)

putDouble

public ByteBuffer putDouble(int index,
                            double value)
Specified by:
putDouble in class ByteBuffer
See Also:
ByteBuffer.putDouble(int, double)

asDoubleBuffer

public DoubleBuffer asDoubleBuffer()
Specified by:
asDoubleBuffer in class ByteBuffer
See Also:
ByteBuffer.asDoubleBuffer()

getHexDump

public String getHexDump()
Description copied from class: ByteBuffer
Returns hexdump of this buffer.

Overrides:
getHexDump in class ByteBuffer

getString

public String getString(int fieldSize,
                        CharsetDecoder decoder)
                 throws CharacterCodingException
Description copied from class: ByteBuffer
Reads a NUL-terminated string from this buffer using the specified decoder and returns it.

Overrides:
getString in class ByteBuffer
Parameters:
fieldSize - the maximum number of bytes to read
Throws:
CharacterCodingException

getString

public String getString(CharsetDecoder decoder)
                 throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
Throws:
CharacterCodingException

getPrefixedString

public String getPrefixedString(CharsetDecoder decoder)
                         throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
Throws:
CharacterCodingException

getPrefixedString

public String getPrefixedString(int prefixLength,
                                CharsetDecoder decoder)
                         throws CharacterCodingException
Description copied from class: ByteBuffer
Reads a string which has a length field before the actual encoded string, using the specified decoder and returns it.

Overrides:
getPrefixedString in class ByteBuffer
Parameters:
prefixLength - the length of the length field (1, 2, or 4)
Throws:
CharacterCodingException

putString

public ByteBuffer putString(CharSequence in,
                            int fieldSize,
                            CharsetEncoder encoder)
                     throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
fieldSize - the maximum number of bytes to write
Throws:
CharacterCodingException

putString

public ByteBuffer putString(CharSequence in,
                            CharsetEncoder encoder)
                     throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
Throws:
CharacterCodingException

putPrefixedString

public ByteBuffer putPrefixedString(CharSequence in,
                                    CharsetEncoder encoder)
                             throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
Throws:
CharacterCodingException

putPrefixedString

public ByteBuffer putPrefixedString(CharSequence in,
                                    int prefixLength,
                                    CharsetEncoder encoder)
                             throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
prefixLength - the length of the length field (1, 2, or 4)
Throws:
CharacterCodingException

putPrefixedString

public ByteBuffer putPrefixedString(CharSequence in,
                                    int prefixLength,
                                    int padding,
                                    CharsetEncoder encoder)
                             throws CharacterCodingException
Description copied from class: ByteBuffer
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 class ByteBuffer
prefixLength - the length of the length field (1, 2, or 4)
padding - the number of padded NULs (1 (or 0), 2, or 4)
Throws:
CharacterCodingException

putPrefixedString

public ByteBuffer putPrefixedString(CharSequence in,
                                    int prefixLength,
                                    int padding,
                                    byte padValue,
                                    CharsetEncoder encoder)
                             throws CharacterCodingException
Description copied from class: ByteBuffer
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 class 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
Throws:
CharacterCodingException

skip

public ByteBuffer skip(int size)
Description copied from class: ByteBuffer
Forwards the position of this buffer as the specified size bytes.

Overrides:
skip in class ByteBuffer

fill

public ByteBuffer fill(byte value,
                       int size)
Description copied from class: ByteBuffer
Fills this buffer with the specified value. This method moves buffer position forward.

Overrides:
fill in class ByteBuffer

fillAndReset

public ByteBuffer fillAndReset(byte value,
                               int size)
Description copied from class: ByteBuffer
Fills this buffer with the specified value. This method does not change buffer position.

Overrides:
fillAndReset in class ByteBuffer

fill

public ByteBuffer fill(int size)
Description copied from class: ByteBuffer
Fills this buffer with NUL (0x00). This method moves buffer position forward.

Overrides:
fill in class ByteBuffer

fillAndReset

public ByteBuffer fillAndReset(int size)
Description copied from class: ByteBuffer
Fills this buffer with NUL (0x00). This method does not change buffer position.

Overrides:
fillAndReset in class ByteBuffer

isAutoExpand

public boolean isAutoExpand()
Description copied from class: ByteBuffer
Returns true if and only if autoExpand is turned on.

Specified by:
isAutoExpand in class ByteBuffer

setAutoExpand

public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class: ByteBuffer
Turns on or off autoExpand.

Specified by:
setAutoExpand in class ByteBuffer

expand

public ByteBuffer expand(int pos,
                         int expectedRemaining)
Description copied from class: ByteBuffer
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.

Specified by:
expand in class ByteBuffer

expand

public ByteBuffer expand(int expectedRemaining)
Description copied from class: ByteBuffer
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 class ByteBuffer

isPooled

public boolean isPooled()
Description copied from class: ByteBuffer
Returns true if and only if this buffer is returned back to the buffer pool when released.

The default value of this property is true if and only if you allocated this buffer using ByteBuffer.allocate(int) or ByteBuffer.allocate(int, boolean), or false otherwise. (i.e. ByteBuffer.wrap(byte[]), ByteBuffer.wrap(byte[], int, int), and ByteBuffer.wrap(java.nio.ByteBuffer))

Specified by:
isPooled in class ByteBuffer

setPooled

public void setPooled(boolean pooled)
Description copied from class: ByteBuffer
Sets whether this buffer is returned back to the buffer pool when released.

The default value of this property is true if and only if you allocated this buffer using ByteBuffer.allocate(int) or ByteBuffer.allocate(int, boolean), or false otherwise. (i.e. ByteBuffer.wrap(byte[]), ByteBuffer.wrap(byte[], int, int), and ByteBuffer.wrap(java.nio.ByteBuffer))

Specified by:
setPooled in class ByteBuffer

getObject

public Object getObject()
                 throws ClassNotFoundException
Description copied from class: ByteBuffer
Reads a Java object from the buffer using the context ClassLoader of the current thread.

Overrides:
getObject in class ByteBuffer
Throws:
ClassNotFoundException

getObject

public Object getObject(ClassLoader classLoader)
                 throws ClassNotFoundException
Description copied from class: ByteBuffer
Reads a Java object from the buffer using the specified classLoader.

Overrides:
getObject in class ByteBuffer
Throws:
ClassNotFoundException

putObject

public ByteBuffer putObject(Object o)
Description copied from class: ByteBuffer
Writes the specified Java object to the buffer.

Overrides:
putObject in class ByteBuffer

asInputStream

public InputStream asInputStream()
Description copied from class: ByteBuffer
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 class ByteBuffer

asOutputStream

public OutputStream asOutputStream()
Description copied from class: ByteBuffer
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.

Overrides:
asOutputStream in class ByteBuffer

duplicate

public ByteBuffer duplicate()
Specified by:
duplicate in class ByteBuffer
See Also:
ByteBuffer.duplicate()

slice

public ByteBuffer slice()
Specified by:
slice in class ByteBuffer
See Also:
ByteBuffer.slice()

asReadOnlyBuffer

public ByteBuffer asReadOnlyBuffer()
Specified by:
asReadOnlyBuffer in class ByteBuffer
See Also:
ByteBuffer.asReadOnlyBuffer()

array

public byte[] array()
Specified by:
array in class ByteBuffer
See Also:
ByteBuffer.array()

arrayOffset

public int arrayOffset()
Specified by:
arrayOffset in class ByteBuffer
See Also:
ByteBuffer.arrayOffset()

capacity

public ByteBuffer capacity(int newCapacity)
Description copied from class: ByteBuffer
Changes the capacity of this buffer.

Specified by:
capacity in class ByteBuffer

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in class ByteBuffer
See Also:
Buffer.isReadOnly()

markValue

public int markValue()
Description copied from class: ByteBuffer
Returns the position of the current mark. This method returns -1 if no mark is set.

Specified by:
markValue in class ByteBuffer


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.