Class ByteBufferProxy
- java.lang.Object
-
- org.apache.mina.common.ByteBuffer
-
- org.apache.mina.common.ByteBufferProxy
-
- All Implemented Interfaces:
java.lang.Comparable<ByteBuffer>
public class ByteBufferProxy extends ByteBuffer
AByteBuffer
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
Fields Modifier and Type Field Description protected ByteBuffer
buf
The buffer proxied by this proxy.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ByteBufferProxy(ByteBuffer buf)
Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire()
Increases the internal reference count of this buffer to defer automatic release.byte[]
array()
int
arrayOffset()
java.nio.CharBuffer
asCharBuffer()
java.nio.DoubleBuffer
asDoubleBuffer()
java.nio.FloatBuffer
asFloatBuffer()
java.io.InputStream
asInputStream()
Returns anInputStream
that reads the data from this buffer.java.nio.IntBuffer
asIntBuffer()
java.nio.LongBuffer
asLongBuffer()
java.io.OutputStream
asOutputStream()
Returns anOutputStream
that appends the data into this buffer.ByteBuffer
asReadOnlyBuffer()
java.nio.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(java.lang.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 withNUL (0x00)
.ByteBuffer
fillAndReset(byte value, int size)
Fills this buffer with the specified value.ByteBuffer
fillAndReset(int size)
Fills this buffer withNUL (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)
java.lang.String
getHexDump()
Returns hexdump of this buffer.int
getInt()
int
getInt(int index)
long
getLong()
long
getLong(int index)
java.lang.Object
getObject()
Reads a Java object from the buffer using the contextClassLoader
of the current thread.java.lang.Object
getObject(java.lang.ClassLoader classLoader)
Reads a Java object from the buffer using the specified classLoader.java.lang.String
getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder)
Reads a string which has a length field before the actual encoded string, using the specifieddecoder
and returns it.java.lang.String
getPrefixedString(java.nio.charset.CharsetDecoder decoder)
Reads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoder
and returns it.short
getShort()
short
getShort(int index)
java.lang.String
getString(int fieldSize, java.nio.charset.CharsetDecoder decoder)
Reads aNUL
-terminated string from this buffer using the specifieddecoder
and returns it.java.lang.String
getString(java.nio.charset.CharsetDecoder decoder)
Reads aNUL
-terminated string from this buffer using the specifieddecoder
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.java.nio.ByteOrder
order()
ByteBuffer
order(java.nio.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(java.lang.Object o)
Writes the specified Java object to the buffer.ByteBuffer
putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
.ByteBuffer
putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
.ByteBuffer
putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
.ByteBuffer
putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
.ByteBuffer
putShort(int index, short value)
ByteBuffer
putShort(short value)
ByteBuffer
putString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer as aNUL
-terminated string using the specifiedencoder
.ByteBuffer
putString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder)
Writes the content ofin
into this buffer using the specifiedencoder
.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 specifiedsize
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.java.lang.String
toString()
-
Methods inherited from class org.apache.mina.common.ByteBuffer
allocate, allocate, autoExpand, autoExpand, getAllocator, isUseDirectBuffers, prefixedDataAvailable, prefixedDataAvailable, setAllocator, setUseDirectBuffers, wrap, wrap, wrap
-
-
-
-
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 invokeByteBuffer.release()
as many as you invoked this method to release this buffer.- Specified by:
acquire
in classByteBuffer
-
release
public void release()
Description copied from class:ByteBuffer
Releases the specified buffer to buffer pool.- Specified by:
release
in classByteBuffer
-
isDirect
public boolean isDirect()
- Specified by:
isDirect
in classByteBuffer
- See Also:
ByteBuffer.isDirect()
-
buf
public java.nio.ByteBuffer buf()
Description copied from class:ByteBuffer
Returns the underlying NIO buffer instance.- Specified by:
buf
in classByteBuffer
-
capacity
public int capacity()
- Specified by:
capacity
in classByteBuffer
- See Also:
Buffer.capacity()
-
position
public int position()
- Specified by:
position
in classByteBuffer
- See Also:
Buffer.position()
-
position
public ByteBuffer position(int newPosition)
- Specified by:
position
in classByteBuffer
- See Also:
Buffer.position(int)
-
limit
public int limit()
- Specified by:
limit
in classByteBuffer
- See Also:
Buffer.limit()
-
limit
public ByteBuffer limit(int newLimit)
- Specified by:
limit
in classByteBuffer
- See Also:
Buffer.limit(int)
-
mark
public ByteBuffer mark()
- Specified by:
mark
in classByteBuffer
- See Also:
Buffer.mark()
-
reset
public ByteBuffer reset()
- Specified by:
reset
in classByteBuffer
- See Also:
Buffer.reset()
-
clear
public ByteBuffer clear()
- Specified by:
clear
in classByteBuffer
- 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 classByteBuffer
-
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 classByteBuffer
-
flip
public ByteBuffer flip()
- Specified by:
flip
in classByteBuffer
- See Also:
Buffer.flip()
-
rewind
public ByteBuffer rewind()
- Specified by:
rewind
in classByteBuffer
- See Also:
Buffer.rewind()
-
remaining
public int remaining()
- Overrides:
remaining
in classByteBuffer
- See Also:
Buffer.remaining()
-
hasRemaining
public boolean hasRemaining()
- Overrides:
hasRemaining
in classByteBuffer
- See Also:
Buffer.hasRemaining()
-
get
public byte get()
- Specified by:
get
in classByteBuffer
- See Also:
ByteBuffer.get()
-
getUnsigned
public short getUnsigned()
Description copied from class:ByteBuffer
Reads one unsigned byte as a short integer.- Overrides:
getUnsigned
in classByteBuffer
-
put
public ByteBuffer put(byte b)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(byte)
-
get
public byte get(int index)
- Specified by:
get
in classByteBuffer
- 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 classByteBuffer
-
put
public ByteBuffer put(int index, byte b)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(int, byte)
-
get
public ByteBuffer get(byte[] dst, int offset, int length)
- Specified by:
get
in classByteBuffer
- See Also:
ByteBuffer.get(byte[], int, int)
-
get
public ByteBuffer get(byte[] dst)
- Overrides:
get
in classByteBuffer
- 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 classByteBuffer
-
put
public ByteBuffer put(java.nio.ByteBuffer src)
Description copied from class:ByteBuffer
Writes the content of the specified src into this buffer.- Specified by:
put
in classByteBuffer
-
put
public ByteBuffer put(byte[] src, int offset, int length)
- Specified by:
put
in classByteBuffer
- See Also:
ByteBuffer.put(byte[], int, int)
-
put
public ByteBuffer put(byte[] src)
- Overrides:
put
in classByteBuffer
- See Also:
ByteBuffer.put(byte[])
-
compact
public ByteBuffer compact()
- Specified by:
compact
in classByteBuffer
- See Also:
ByteBuffer.compact()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classByteBuffer
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classByteBuffer
-
equals
public boolean equals(java.lang.Object ob)
- Overrides:
equals
in classByteBuffer
-
compareTo
public int compareTo(ByteBuffer that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ByteBuffer>
- Overrides:
compareTo
in classByteBuffer
-
order
public java.nio.ByteOrder order()
- Specified by:
order
in classByteBuffer
- See Also:
ByteBuffer.order()
-
order
public ByteBuffer order(java.nio.ByteOrder bo)
- Specified by:
order
in classByteBuffer
- See Also:
ByteBuffer.order(ByteOrder)
-
getChar
public char getChar()
- Specified by:
getChar
in classByteBuffer
- See Also:
ByteBuffer.getChar()
-
putChar
public ByteBuffer putChar(char value)
- Specified by:
putChar
in classByteBuffer
- See Also:
ByteBuffer.putChar(char)
-
getChar
public char getChar(int index)
- Specified by:
getChar
in classByteBuffer
- See Also:
ByteBuffer.getChar(int)
-
putChar
public ByteBuffer putChar(int index, char value)
- Specified by:
putChar
in classByteBuffer
- See Also:
ByteBuffer.putChar(int, char)
-
asCharBuffer
public java.nio.CharBuffer asCharBuffer()
- Specified by:
asCharBuffer
in classByteBuffer
- See Also:
ByteBuffer.asCharBuffer()
-
getShort
public short getShort()
- Specified by:
getShort
in classByteBuffer
- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort()
Description copied from class:ByteBuffer
Reads two bytes unsigned integer.- Overrides:
getUnsignedShort
in classByteBuffer
-
putShort
public ByteBuffer putShort(short value)
- Specified by:
putShort
in classByteBuffer
- See Also:
ByteBuffer.putShort(short)
-
getShort
public short getShort(int index)
- Specified by:
getShort
in classByteBuffer
- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort(int index)
Description copied from class:ByteBuffer
Reads two bytes unsigned integer.- Overrides:
getUnsignedShort
in classByteBuffer
-
putShort
public ByteBuffer putShort(int index, short value)
- Specified by:
putShort
in classByteBuffer
- See Also:
ByteBuffer.putShort(int, short)
-
asShortBuffer
public java.nio.ShortBuffer asShortBuffer()
- Specified by:
asShortBuffer
in classByteBuffer
- See Also:
ByteBuffer.asShortBuffer()
-
getInt
public int getInt()
- Specified by:
getInt
in classByteBuffer
- See Also:
ByteBuffer.getInt()
-
getUnsignedInt
public long getUnsignedInt()
Description copied from class:ByteBuffer
Reads four bytes unsigned integer.- Overrides:
getUnsignedInt
in classByteBuffer
-
putInt
public ByteBuffer putInt(int value)
- Specified by:
putInt
in classByteBuffer
- See Also:
ByteBuffer.putInt(int)
-
getInt
public int getInt(int index)
- Specified by:
getInt
in classByteBuffer
- See Also:
ByteBuffer.getInt(int)
-
getUnsignedInt
public long getUnsignedInt(int index)
Description copied from class:ByteBuffer
Reads four bytes unsigned integer.- Overrides:
getUnsignedInt
in classByteBuffer
-
putInt
public ByteBuffer putInt(int index, int value)
- Specified by:
putInt
in classByteBuffer
- See Also:
ByteBuffer.putInt(int, int)
-
asIntBuffer
public java.nio.IntBuffer asIntBuffer()
- Specified by:
asIntBuffer
in classByteBuffer
- See Also:
ByteBuffer.asIntBuffer()
-
getLong
public long getLong()
- Specified by:
getLong
in classByteBuffer
- See Also:
ByteBuffer.getLong()
-
putLong
public ByteBuffer putLong(long value)
- Specified by:
putLong
in classByteBuffer
- See Also:
ByteBuffer.putLong(int, long)
-
getLong
public long getLong(int index)
- Specified by:
getLong
in classByteBuffer
- See Also:
ByteBuffer.getLong(int)
-
putLong
public ByteBuffer putLong(int index, long value)
- Specified by:
putLong
in classByteBuffer
- See Also:
ByteBuffer.putLong(int, long)
-
asLongBuffer
public java.nio.LongBuffer asLongBuffer()
- Specified by:
asLongBuffer
in classByteBuffer
- See Also:
ByteBuffer.asLongBuffer()
-
getFloat
public float getFloat()
- Specified by:
getFloat
in classByteBuffer
- See Also:
ByteBuffer.getFloat()
-
putFloat
public ByteBuffer putFloat(float value)
- Specified by:
putFloat
in classByteBuffer
- See Also:
ByteBuffer.putFloat(float)
-
getFloat
public float getFloat(int index)
- Specified by:
getFloat
in classByteBuffer
- See Also:
ByteBuffer.getFloat(int)
-
putFloat
public ByteBuffer putFloat(int index, float value)
- Specified by:
putFloat
in classByteBuffer
- See Also:
ByteBuffer.putFloat(int, float)
-
asFloatBuffer
public java.nio.FloatBuffer asFloatBuffer()
- Specified by:
asFloatBuffer
in classByteBuffer
- See Also:
ByteBuffer.asFloatBuffer()
-
getDouble
public double getDouble()
- Specified by:
getDouble
in classByteBuffer
- See Also:
ByteBuffer.getDouble()
-
putDouble
public ByteBuffer putDouble(double value)
- Specified by:
putDouble
in classByteBuffer
- See Also:
ByteBuffer.putDouble(double)
-
getDouble
public double getDouble(int index)
- Specified by:
getDouble
in classByteBuffer
- See Also:
ByteBuffer.getDouble(int)
-
putDouble
public ByteBuffer putDouble(int index, double value)
- Specified by:
putDouble
in classByteBuffer
- See Also:
ByteBuffer.putDouble(int, double)
-
asDoubleBuffer
public java.nio.DoubleBuffer asDoubleBuffer()
- Specified by:
asDoubleBuffer
in classByteBuffer
- See Also:
ByteBuffer.asDoubleBuffer()
-
getHexDump
public java.lang.String getHexDump()
Description copied from class:ByteBuffer
Returns hexdump of this buffer.- Overrides:
getHexDump
in classByteBuffer
-
getString
public java.lang.String getString(int fieldSize, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Reads aNUL
-terminated string from this buffer using the specifieddecoder
and returns it.- Overrides:
getString
in classByteBuffer
- Parameters:
fieldSize
- the maximum number of bytes to read- Throws:
java.nio.charset.CharacterCodingException
-
getString
public java.lang.String getString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Reads aNUL
-terminated string from this buffer using the specifieddecoder
and returns it. This method reads until the limit of this buffer if no NUL is found.- Overrides:
getString
in classByteBuffer
- Throws:
java.nio.charset.CharacterCodingException
-
getPrefixedString
public java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Reads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoder
and returns it. This method is a shortcut for getPrefixedString(2, decoder).- Overrides:
getPrefixedString
in classByteBuffer
- Throws:
java.nio.charset.CharacterCodingException
-
getPrefixedString
public java.lang.String getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Reads a string which has a length field before the actual encoded string, using the specifieddecoder
and returns it.- Overrides:
getPrefixedString
in classByteBuffer
- Parameters:
prefixLength
- the length of the length field (1, 2, or 4)- Throws:
java.nio.charset.CharacterCodingException
-
putString
public ByteBuffer putString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer as aNUL
-terminated string using the specifiedencoder
.If the charset name of the encoder is UTF-16, you cannot specify odd
fieldSize
, and this method will append twoNUL
s as a terminator.Please note that this method doesn't terminate with
NUL
if the input string is longer than fieldSize.- Overrides:
putString
in classByteBuffer
fieldSize
- the maximum number of bytes to write- Throws:
java.nio.charset.CharacterCodingException
-
putString
public ByteBuffer putString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer using the specifiedencoder
. This method doesn't terminate string with NUL. You have to do it by yourself.- Overrides:
putString
in classByteBuffer
- Throws:
java.nio.charset.CharacterCodingException
-
putPrefixedString
public ByteBuffer putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
. This method is a shortcut for putPrefixedString(in, 2, 0, encoder).- Overrides:
putPrefixedString
in classByteBuffer
- Throws:
java.nio.charset.CharacterCodingException
-
putPrefixedString
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
. This method is a shortcut for putPrefixedString(in, prefixLength, 0, encoder).- Overrides:
putPrefixedString
in classByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)- Throws:
java.nio.charset.CharacterCodingException
-
putPrefixedString
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
. This method is a shortcut for putPrefixedString(in, prefixLength, padding, ( byte ) 0, encoder).- Overrides:
putPrefixedString
in classByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)padding
- the number of padded NULs (1 (or 0), 2, or 4)- Throws:
java.nio.charset.CharacterCodingException
-
putPrefixedString
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
Description copied from class:ByteBuffer
Writes the content ofin
into this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder
.- Overrides:
putPrefixedString
in classByteBuffer
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:
java.nio.charset.CharacterCodingException
-
skip
public ByteBuffer skip(int size)
Description copied from class:ByteBuffer
Forwards the position of this buffer as the specifiedsize
bytes.- Overrides:
skip
in classByteBuffer
-
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 classByteBuffer
-
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 classByteBuffer
-
fill
public ByteBuffer fill(int size)
Description copied from class:ByteBuffer
Fills this buffer withNUL (0x00)
. This method moves buffer position forward.- Overrides:
fill
in classByteBuffer
-
fillAndReset
public ByteBuffer fillAndReset(int size)
Description copied from class:ByteBuffer
Fills this buffer withNUL (0x00)
. This method does not change buffer position.- Overrides:
fillAndReset
in classByteBuffer
-
isAutoExpand
public boolean isAutoExpand()
Description copied from class:ByteBuffer
Returns true if and only if autoExpand is turned on.- Specified by:
isAutoExpand
in classByteBuffer
-
setAutoExpand
public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class:ByteBuffer
Turns on or off autoExpand.- Specified by:
setAutoExpand
in classByteBuffer
-
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 classByteBuffer
-
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 classByteBuffer
-
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)
orByteBuffer.allocate(int, boolean)
, or false otherwise. (i.e.ByteBuffer.wrap(byte[])
,ByteBuffer.wrap(byte[], int, int)
, andByteBuffer.wrap(java.nio.ByteBuffer)
)- Specified by:
isPooled
in classByteBuffer
-
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)
orByteBuffer.allocate(int, boolean)
, or false otherwise. (i.e.ByteBuffer.wrap(byte[])
,ByteBuffer.wrap(byte[], int, int)
, andByteBuffer.wrap(java.nio.ByteBuffer)
)- Specified by:
setPooled
in classByteBuffer
-
getObject
public java.lang.Object getObject() throws java.lang.ClassNotFoundException
Description copied from class:ByteBuffer
Reads a Java object from the buffer using the contextClassLoader
of the current thread.- Overrides:
getObject
in classByteBuffer
- Throws:
java.lang.ClassNotFoundException
-
getObject
public java.lang.Object getObject(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
Description copied from class:ByteBuffer
Reads a Java object from the buffer using the specified classLoader.- Overrides:
getObject
in classByteBuffer
- Throws:
java.lang.ClassNotFoundException
-
putObject
public ByteBuffer putObject(java.lang.Object o)
Description copied from class:ByteBuffer
Writes the specified Java object to the buffer.- Overrides:
putObject
in classByteBuffer
-
asInputStream
public java.io.InputStream asInputStream()
Description copied from class:ByteBuffer
Returns anInputStream
that reads the data from this buffer.InputStream.read()
returns -1 if the buffer position reaches to the limit.- Overrides:
asInputStream
in classByteBuffer
-
asOutputStream
public java.io.OutputStream asOutputStream()
Description copied from class:ByteBuffer
Returns anOutputStream
that appends the data into this buffer. Please note that theOutputStream.write(int)
will throw aBufferOverflowException
instead of anIOException
in case of buffer overflow. Please set autoExpand property by callingByteBuffer.setAutoExpand(boolean)
to prevent the unexpected runtime exception.- Overrides:
asOutputStream
in classByteBuffer
-
duplicate
public ByteBuffer duplicate()
- Specified by:
duplicate
in classByteBuffer
- See Also:
ByteBuffer.duplicate()
-
slice
public ByteBuffer slice()
- Specified by:
slice
in classByteBuffer
- See Also:
ByteBuffer.slice()
-
asReadOnlyBuffer
public ByteBuffer asReadOnlyBuffer()
- Specified by:
asReadOnlyBuffer
in classByteBuffer
- See Also:
ByteBuffer.asReadOnlyBuffer()
-
array
public byte[] array()
- Specified by:
array
in classByteBuffer
- See Also:
ByteBuffer.array()
-
arrayOffset
public int arrayOffset()
- Specified by:
arrayOffset
in classByteBuffer
- 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 classByteBuffer
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in classByteBuffer
- 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 classByteBuffer
-
-