|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.common.ByteBuffer
org.apache.mina.common.ByteBufferProxy
public class ByteBufferProxy
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 | |
|---|---|
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 |
|---|
protected ByteBuffer buf
| Constructor Detail |
|---|
protected ByteBufferProxy(ByteBuffer buf)
buf - the buffer to be proxied| Method Detail |
|---|
public void acquire()
ByteBufferByteBuffer.release() as many
as you invoked this method to release this buffer.
acquire in class ByteBufferpublic void release()
ByteBuffer
release in class ByteBufferpublic boolean isDirect()
isDirect in class ByteBufferByteBuffer.isDirect()public ByteBuffer buf()
ByteBuffer
buf in class ByteBufferpublic int capacity()
capacity in class ByteBufferBuffer.capacity()public int position()
position in class ByteBufferBuffer.position()public ByteBuffer position(int newPosition)
position in class ByteBufferBuffer.position(int)public int limit()
limit in class ByteBufferBuffer.limit()public ByteBuffer limit(int newLimit)
limit in class ByteBufferBuffer.limit(int)public ByteBuffer mark()
mark in class ByteBufferBuffer.mark()public ByteBuffer reset()
reset in class ByteBufferBuffer.reset()public ByteBuffer clear()
clear in class ByteBufferBuffer.clear()public ByteBuffer sweep()
ByteBuffer
sweep in class ByteBufferpublic ByteBuffer sweep(byte value)
ByteBuffer
sweep in class ByteBufferpublic ByteBuffer flip()
flip in class ByteBufferBuffer.flip()public ByteBuffer rewind()
rewind in class ByteBufferBuffer.rewind()public int remaining()
remaining in class ByteBufferBuffer.remaining()public boolean hasRemaining()
hasRemaining in class ByteBufferBuffer.hasRemaining()public byte get()
get in class ByteBufferByteBuffer.get()public short getUnsigned()
ByteBuffer
getUnsigned in class ByteBufferpublic ByteBuffer put(byte b)
put in class ByteBufferByteBuffer.put(byte)public byte get(int index)
get in class ByteBufferByteBuffer.get(int)public short getUnsigned(int index)
ByteBuffer
getUnsigned in class ByteBuffer
public ByteBuffer put(int index,
byte b)
put in class ByteBufferByteBuffer.put(int, byte)
public ByteBuffer get(byte[] dst,
int offset,
int length)
get in class ByteBufferByteBuffer.get(byte[], int, int)public ByteBuffer get(byte[] dst)
get in class ByteBufferByteBuffer.get(byte[])public ByteBuffer put(ByteBuffer src)
ByteBuffer
put in class ByteBufferpublic ByteBuffer put(ByteBuffer src)
ByteBuffer
put in class ByteBuffer
public ByteBuffer put(byte[] src,
int offset,
int length)
put in class ByteBufferByteBuffer.put(byte[], int, int)public ByteBuffer put(byte[] src)
put in class ByteBufferByteBuffer.put(byte[])public ByteBuffer compact()
compact in class ByteBufferByteBuffer.compact()public String toString()
toString in class ByteBufferpublic int hashCode()
hashCode in class ByteBufferpublic boolean equals(Object ob)
equals in class ByteBufferpublic int compareTo(ByteBuffer that)
compareTo in interface Comparable<ByteBuffer>compareTo in class ByteBufferpublic ByteOrder order()
order in class ByteBufferByteBuffer.order()public ByteBuffer order(ByteOrder bo)
order in class ByteBufferByteBuffer.order(ByteOrder)public char getChar()
getChar in class ByteBufferByteBuffer.getChar()public ByteBuffer putChar(char value)
putChar in class ByteBufferByteBuffer.putChar(char)public char getChar(int index)
getChar in class ByteBufferByteBuffer.getChar(int)
public ByteBuffer putChar(int index,
char value)
putChar in class ByteBufferByteBuffer.putChar(int, char)public CharBuffer asCharBuffer()
asCharBuffer in class ByteBufferByteBuffer.asCharBuffer()public short getShort()
getShort in class ByteBufferByteBuffer.getShort()public int getUnsignedShort()
ByteBuffer
getUnsignedShort in class ByteBufferpublic ByteBuffer putShort(short value)
putShort in class ByteBufferByteBuffer.putShort(short)public short getShort(int index)
getShort in class ByteBufferByteBuffer.getShort()public int getUnsignedShort(int index)
ByteBuffer
getUnsignedShort in class ByteBuffer
public ByteBuffer putShort(int index,
short value)
putShort in class ByteBufferByteBuffer.putShort(int, short)public ShortBuffer asShortBuffer()
asShortBuffer in class ByteBufferByteBuffer.asShortBuffer()public int getInt()
getInt in class ByteBufferByteBuffer.getInt()public long getUnsignedInt()
ByteBuffer
getUnsignedInt in class ByteBufferpublic ByteBuffer putInt(int value)
putInt in class ByteBufferByteBuffer.putInt(int)public int getInt(int index)
getInt in class ByteBufferByteBuffer.getInt(int)public long getUnsignedInt(int index)
ByteBuffer
getUnsignedInt in class ByteBuffer
public ByteBuffer putInt(int index,
int value)
putInt in class ByteBufferByteBuffer.putInt(int, int)public IntBuffer asIntBuffer()
asIntBuffer in class ByteBufferByteBuffer.asIntBuffer()public long getLong()
getLong in class ByteBufferByteBuffer.getLong()public ByteBuffer putLong(long value)
putLong in class ByteBufferByteBuffer.putLong(int, long)public long getLong(int index)
getLong in class ByteBufferByteBuffer.getLong(int)
public ByteBuffer putLong(int index,
long value)
putLong in class ByteBufferByteBuffer.putLong(int, long)public LongBuffer asLongBuffer()
asLongBuffer in class ByteBufferByteBuffer.asLongBuffer()public float getFloat()
getFloat in class ByteBufferByteBuffer.getFloat()public ByteBuffer putFloat(float value)
putFloat in class ByteBufferByteBuffer.putFloat(float)public float getFloat(int index)
getFloat in class ByteBufferByteBuffer.getFloat(int)
public ByteBuffer putFloat(int index,
float value)
putFloat in class ByteBufferByteBuffer.putFloat(int, float)public FloatBuffer asFloatBuffer()
asFloatBuffer in class ByteBufferByteBuffer.asFloatBuffer()public double getDouble()
getDouble in class ByteBufferByteBuffer.getDouble()public ByteBuffer putDouble(double value)
putDouble in class ByteBufferByteBuffer.putDouble(double)public double getDouble(int index)
getDouble in class ByteBufferByteBuffer.getDouble(int)
public ByteBuffer putDouble(int index,
double value)
putDouble in class ByteBufferByteBuffer.putDouble(int, double)public DoubleBuffer asDoubleBuffer()
asDoubleBuffer in class ByteBufferByteBuffer.asDoubleBuffer()public String getHexDump()
ByteBuffer
getHexDump in class ByteBuffer
public String getString(int fieldSize,
CharsetDecoder decoder)
throws CharacterCodingException
ByteBufferNUL-terminated string from this buffer using the
specified decoder and returns it.
getString in class ByteBufferfieldSize - the maximum number of bytes to read
CharacterCodingException
public String getString(CharsetDecoder decoder)
throws CharacterCodingException
ByteBufferNUL-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 class ByteBufferCharacterCodingException
public String getPrefixedString(CharsetDecoder decoder)
throws CharacterCodingException
ByteBufferdecoder and returns it.
This method is a shortcut for getPrefixedString(2, decoder).
getPrefixedString in class ByteBufferCharacterCodingException
public String getPrefixedString(int prefixLength,
CharsetDecoder decoder)
throws CharacterCodingException
ByteBufferdecoder and returns it.
getPrefixedString in class ByteBufferprefixLength - the length of the length field (1, 2, or 4)
CharacterCodingException
public ByteBuffer putString(CharSequence in,
int fieldSize,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin 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.
putString in class ByteBufferfieldSize - the maximum number of bytes to write
CharacterCodingException
public ByteBuffer putString(CharSequence in,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin into this buffer using the
specified encoder. This method doesn't terminate
string with NUL. You have to do it by yourself.
putString in class ByteBufferCharacterCodingException
public ByteBuffer putPrefixedString(CharSequence in,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin 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 class ByteBufferCharacterCodingException
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin 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 class ByteBufferprefixLength - the length of the length field (1, 2, or 4)
CharacterCodingException
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
int padding,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin 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 class ByteBufferprefixLength - the length of the length field (1, 2, or 4)padding - the number of padded NULs (1 (or 0), 2, or 4)
CharacterCodingException
public ByteBuffer putPrefixedString(CharSequence in,
int prefixLength,
int padding,
byte padValue,
CharsetEncoder encoder)
throws CharacterCodingException
ByteBufferin into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder.
putPrefixedString in class ByteBufferprefixLength - 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
CharacterCodingExceptionpublic ByteBuffer skip(int size)
ByteBuffersize
bytes.
skip in class ByteBuffer
public ByteBuffer fill(byte value,
int size)
ByteBuffer
fill in class ByteBuffer
public ByteBuffer fillAndReset(byte value,
int size)
ByteBuffer
fillAndReset in class ByteBufferpublic ByteBuffer fill(int size)
ByteBufferNUL (0x00).
This method moves buffer position forward.
fill in class ByteBufferpublic ByteBuffer fillAndReset(int size)
ByteBufferNUL (0x00).
This method does not change buffer position.
fillAndReset in class ByteBufferpublic boolean isAutoExpand()
ByteBuffer
isAutoExpand in class ByteBufferpublic ByteBuffer setAutoExpand(boolean autoExpand)
ByteBuffer
setAutoExpand in class ByteBuffer
public ByteBuffer expand(int pos,
int expectedRemaining)
ByteBuffer
expand in class ByteBufferpublic ByteBuffer expand(int expectedRemaining)
ByteBuffer
expand in class ByteBufferpublic boolean isPooled()
ByteBuffer
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))
isPooled in class ByteBufferpublic void setPooled(boolean pooled)
ByteBuffer
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))
setPooled in class ByteBuffer
public Object getObject()
throws ClassNotFoundException
ByteBufferClassLoader
of the current thread.
getObject in class ByteBufferClassNotFoundException
public Object getObject(ClassLoader classLoader)
throws ClassNotFoundException
ByteBuffer
getObject in class ByteBufferClassNotFoundExceptionpublic ByteBuffer putObject(Object o)
ByteBuffer
putObject in class ByteBufferpublic InputStream asInputStream()
ByteBufferInputStream that reads the data from this buffer.
InputStream.read() returns -1 if the buffer position
reaches to the limit.
asInputStream in class ByteBufferpublic OutputStream asOutputStream()
ByteBufferOutputStream 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 class ByteBufferpublic ByteBuffer duplicate()
duplicate in class ByteBufferByteBuffer.duplicate()public ByteBuffer slice()
slice in class ByteBufferByteBuffer.slice()public ByteBuffer asReadOnlyBuffer()
asReadOnlyBuffer in class ByteBufferByteBuffer.asReadOnlyBuffer()public byte[] array()
array in class ByteBufferByteBuffer.array()public int arrayOffset()
arrayOffset in class ByteBufferByteBuffer.arrayOffset()public ByteBuffer capacity(int newCapacity)
ByteBuffer
capacity in class ByteBufferpublic boolean isReadOnly()
isReadOnly in class ByteBufferBuffer.isReadOnly()public int markValue()
ByteBuffer
markValue in class ByteBuffer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||