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
AByteBufferthat 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 ByteBufferbufThe buffer proxied by this proxy.
-
Constructor Summary
Constructors Modifier Constructor Description protectedByteBufferProxy(ByteBuffer buf)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquire()Increases the internal reference count of this buffer to defer automatic release.byte[]array()intarrayOffset()java.nio.CharBufferasCharBuffer()java.nio.DoubleBufferasDoubleBuffer()java.nio.FloatBufferasFloatBuffer()java.io.InputStreamasInputStream()Returns anInputStreamthat reads the data from this buffer.java.nio.IntBufferasIntBuffer()java.nio.LongBufferasLongBuffer()java.io.OutputStreamasOutputStream()Returns anOutputStreamthat appends the data into this buffer.ByteBufferasReadOnlyBuffer()java.nio.ShortBufferasShortBuffer()java.nio.ByteBufferbuf()Returns the underlying NIO buffer instance.intcapacity()ByteBuffercapacity(int newCapacity)Changes the capacity of this buffer.ByteBufferclear()ByteBuffercompact()intcompareTo(ByteBuffer that)ByteBufferduplicate()booleanequals(java.lang.Object ob)ByteBufferexpand(int expectedRemaining)Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the current position.ByteBufferexpand(int pos, int expectedRemaining)Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos.ByteBufferfill(byte value, int size)Fills this buffer with the specified value.ByteBufferfill(int size)Fills this buffer withNUL (0x00).ByteBufferfillAndReset(byte value, int size)Fills this buffer with the specified value.ByteBufferfillAndReset(int size)Fills this buffer withNUL (0x00).ByteBufferflip()byteget()ByteBufferget(byte[] dst)ByteBufferget(byte[] dst, int offset, int length)byteget(int index)chargetChar()chargetChar(int index)doublegetDouble()doublegetDouble(int index)floatgetFloat()floatgetFloat(int index)java.lang.StringgetHexDump()Returns hexdump of this buffer.intgetInt()intgetInt(int index)longgetLong()longgetLong(int index)java.lang.ObjectgetObject()Reads a Java object from the buffer using the contextClassLoaderof the current thread.java.lang.ObjectgetObject(java.lang.ClassLoader classLoader)Reads a Java object from the buffer using the specified classLoader.java.lang.StringgetPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder)Reads a string which has a length field before the actual encoded string, using the specifieddecoderand returns it.java.lang.StringgetPrefixedString(java.nio.charset.CharsetDecoder decoder)Reads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoderand returns it.shortgetShort()shortgetShort(int index)java.lang.StringgetString(int fieldSize, java.nio.charset.CharsetDecoder decoder)Reads aNUL-terminated string from this buffer using the specifieddecoderand returns it.java.lang.StringgetString(java.nio.charset.CharsetDecoder decoder)Reads aNUL-terminated string from this buffer using the specifieddecoderand returns it.shortgetUnsigned()Reads one unsigned byte as a short integer.shortgetUnsigned(int index)Reads one byte as an unsigned short integer.longgetUnsignedInt()Reads four bytes unsigned integer.longgetUnsignedInt(int index)Reads four bytes unsigned integer.intgetUnsignedShort()Reads two bytes unsigned integer.intgetUnsignedShort(int index)Reads two bytes unsigned integer.inthashCode()booleanhasRemaining()booleanisAutoExpand()Returns true if and only if autoExpand is turned on.booleanisDirect()booleanisPooled()Returns true if and only if this buffer is returned back to the buffer pool when released.booleanisReadOnly()intlimit()ByteBufferlimit(int newLimit)ByteBuffermark()intmarkValue()Returns the position of the current mark.java.nio.ByteOrderorder()ByteBufferorder(java.nio.ByteOrder bo)intposition()ByteBufferposition(int newPosition)ByteBufferput(byte b)ByteBufferput(byte[] src)ByteBufferput(byte[] src, int offset, int length)ByteBufferput(int index, byte b)ByteBufferput(java.nio.ByteBuffer src)Writes the content of the specified src into this buffer.ByteBufferput(ByteBuffer src)Writes the content of the specified src into this buffer.ByteBufferputChar(char value)ByteBufferputChar(int index, char value)ByteBufferputDouble(double value)ByteBufferputDouble(int index, double value)ByteBufferputFloat(float value)ByteBufferputFloat(int index, float value)ByteBufferputInt(int value)ByteBufferputInt(int index, int value)ByteBufferputLong(int index, long value)ByteBufferputLong(long value)ByteBufferputObject(java.lang.Object o)Writes the specified Java object to the buffer.ByteBufferputPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.ByteBufferputPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.ByteBufferputPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.ByteBufferputPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.ByteBufferputShort(int index, short value)ByteBufferputShort(short value)ByteBufferputString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer as aNUL-terminated string using the specifiedencoder.ByteBufferputString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder)Writes the content ofininto this buffer using the specifiedencoder.voidrelease()Releases the specified buffer to buffer pool.intremaining()ByteBufferreset()ByteBufferrewind()ByteBuffersetAutoExpand(boolean autoExpand)Turns on or off autoExpand.voidsetPooled(boolean pooled)Sets whether this buffer is returned back to the buffer pool when released.ByteBufferskip(int size)Forwards the position of this buffer as the specifiedsizebytes.ByteBufferslice()ByteBuffersweep()Clears this buffer and fills its content with NUL.ByteBuffersweep(byte value)Clears this buffer and fills its content with value.java.lang.StringtoString()-
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:ByteBufferIncreases 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:
acquirein classByteBuffer
-
release
public void release()
Description copied from class:ByteBufferReleases the specified buffer to buffer pool.- Specified by:
releasein classByteBuffer
-
isDirect
public boolean isDirect()
- Specified by:
isDirectin classByteBuffer- See Also:
ByteBuffer.isDirect()
-
buf
public java.nio.ByteBuffer buf()
Description copied from class:ByteBufferReturns the underlying NIO buffer instance.- Specified by:
bufin classByteBuffer
-
capacity
public int capacity()
- Specified by:
capacityin classByteBuffer- See Also:
Buffer.capacity()
-
position
public int position()
- Specified by:
positionin classByteBuffer- See Also:
Buffer.position()
-
position
public ByteBuffer position(int newPosition)
- Specified by:
positionin classByteBuffer- See Also:
Buffer.position(int)
-
limit
public int limit()
- Specified by:
limitin classByteBuffer- See Also:
Buffer.limit()
-
limit
public ByteBuffer limit(int newLimit)
- Specified by:
limitin classByteBuffer- See Also:
Buffer.limit(int)
-
mark
public ByteBuffer mark()
- Specified by:
markin classByteBuffer- See Also:
Buffer.mark()
-
reset
public ByteBuffer reset()
- Specified by:
resetin classByteBuffer- See Also:
Buffer.reset()
-
clear
public ByteBuffer clear()
- Specified by:
clearin classByteBuffer- See Also:
Buffer.clear()
-
sweep
public ByteBuffer sweep()
Description copied from class:ByteBufferClears 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:
sweepin classByteBuffer
-
sweep
public ByteBuffer sweep(byte value)
Description copied from class:ByteBufferClears 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:
sweepin classByteBuffer
-
flip
public ByteBuffer flip()
- Specified by:
flipin classByteBuffer- See Also:
Buffer.flip()
-
rewind
public ByteBuffer rewind()
- Specified by:
rewindin classByteBuffer- See Also:
Buffer.rewind()
-
remaining
public int remaining()
- Overrides:
remainingin classByteBuffer- See Also:
Buffer.remaining()
-
hasRemaining
public boolean hasRemaining()
- Overrides:
hasRemainingin classByteBuffer- See Also:
Buffer.hasRemaining()
-
get
public byte get()
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get()
-
getUnsigned
public short getUnsigned()
Description copied from class:ByteBufferReads one unsigned byte as a short integer.- Overrides:
getUnsignedin classByteBuffer
-
put
public ByteBuffer put(byte b)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(byte)
-
get
public byte get(int index)
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get(int)
-
getUnsigned
public short getUnsigned(int index)
Description copied from class:ByteBufferReads one byte as an unsigned short integer.- Overrides:
getUnsignedin classByteBuffer
-
put
public ByteBuffer put(int index, byte b)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(int, byte)
-
get
public ByteBuffer get(byte[] dst, int offset, int length)
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get(byte[], int, int)
-
get
public ByteBuffer get(byte[] dst)
- Overrides:
getin classByteBuffer- See Also:
ByteBuffer.get(byte[])
-
put
public ByteBuffer put(ByteBuffer src)
Description copied from class:ByteBufferWrites the content of the specified src into this buffer.- Overrides:
putin classByteBuffer
-
put
public ByteBuffer put(java.nio.ByteBuffer src)
Description copied from class:ByteBufferWrites the content of the specified src into this buffer.- Specified by:
putin classByteBuffer
-
put
public ByteBuffer put(byte[] src, int offset, int length)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(byte[], int, int)
-
put
public ByteBuffer put(byte[] src)
- Overrides:
putin classByteBuffer- See Also:
ByteBuffer.put(byte[])
-
compact
public ByteBuffer compact()
- Specified by:
compactin classByteBuffer- See Also:
ByteBuffer.compact()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classByteBuffer
-
hashCode
public int hashCode()
- Overrides:
hashCodein classByteBuffer
-
equals
public boolean equals(java.lang.Object ob)
- Overrides:
equalsin classByteBuffer
-
compareTo
public int compareTo(ByteBuffer that)
- Specified by:
compareToin interfacejava.lang.Comparable<ByteBuffer>- Overrides:
compareToin classByteBuffer
-
order
public java.nio.ByteOrder order()
- Specified by:
orderin classByteBuffer- See Also:
ByteBuffer.order()
-
order
public ByteBuffer order(java.nio.ByteOrder bo)
- Specified by:
orderin classByteBuffer- See Also:
ByteBuffer.order(ByteOrder)
-
getChar
public char getChar()
- Specified by:
getCharin classByteBuffer- See Also:
ByteBuffer.getChar()
-
putChar
public ByteBuffer putChar(char value)
- Specified by:
putCharin classByteBuffer- See Also:
ByteBuffer.putChar(char)
-
getChar
public char getChar(int index)
- Specified by:
getCharin classByteBuffer- See Also:
ByteBuffer.getChar(int)
-
putChar
public ByteBuffer putChar(int index, char value)
- Specified by:
putCharin classByteBuffer- See Also:
ByteBuffer.putChar(int, char)
-
asCharBuffer
public java.nio.CharBuffer asCharBuffer()
- Specified by:
asCharBufferin classByteBuffer- See Also:
ByteBuffer.asCharBuffer()
-
getShort
public short getShort()
- Specified by:
getShortin classByteBuffer- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort()
Description copied from class:ByteBufferReads two bytes unsigned integer.- Overrides:
getUnsignedShortin classByteBuffer
-
putShort
public ByteBuffer putShort(short value)
- Specified by:
putShortin classByteBuffer- See Also:
ByteBuffer.putShort(short)
-
getShort
public short getShort(int index)
- Specified by:
getShortin classByteBuffer- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort(int index)
Description copied from class:ByteBufferReads two bytes unsigned integer.- Overrides:
getUnsignedShortin classByteBuffer
-
putShort
public ByteBuffer putShort(int index, short value)
- Specified by:
putShortin classByteBuffer- See Also:
ByteBuffer.putShort(int, short)
-
asShortBuffer
public java.nio.ShortBuffer asShortBuffer()
- Specified by:
asShortBufferin classByteBuffer- See Also:
ByteBuffer.asShortBuffer()
-
getInt
public int getInt()
- Specified by:
getIntin classByteBuffer- See Also:
ByteBuffer.getInt()
-
getUnsignedInt
public long getUnsignedInt()
Description copied from class:ByteBufferReads four bytes unsigned integer.- Overrides:
getUnsignedIntin classByteBuffer
-
putInt
public ByteBuffer putInt(int value)
- Specified by:
putIntin classByteBuffer- See Also:
ByteBuffer.putInt(int)
-
getInt
public int getInt(int index)
- Specified by:
getIntin classByteBuffer- See Also:
ByteBuffer.getInt(int)
-
getUnsignedInt
public long getUnsignedInt(int index)
Description copied from class:ByteBufferReads four bytes unsigned integer.- Overrides:
getUnsignedIntin classByteBuffer
-
putInt
public ByteBuffer putInt(int index, int value)
- Specified by:
putIntin classByteBuffer- See Also:
ByteBuffer.putInt(int, int)
-
asIntBuffer
public java.nio.IntBuffer asIntBuffer()
- Specified by:
asIntBufferin classByteBuffer- See Also:
ByteBuffer.asIntBuffer()
-
getLong
public long getLong()
- Specified by:
getLongin classByteBuffer- See Also:
ByteBuffer.getLong()
-
putLong
public ByteBuffer putLong(long value)
- Specified by:
putLongin classByteBuffer- See Also:
ByteBuffer.putLong(int, long)
-
getLong
public long getLong(int index)
- Specified by:
getLongin classByteBuffer- See Also:
ByteBuffer.getLong(int)
-
putLong
public ByteBuffer putLong(int index, long value)
- Specified by:
putLongin classByteBuffer- See Also:
ByteBuffer.putLong(int, long)
-
asLongBuffer
public java.nio.LongBuffer asLongBuffer()
- Specified by:
asLongBufferin classByteBuffer- See Also:
ByteBuffer.asLongBuffer()
-
getFloat
public float getFloat()
- Specified by:
getFloatin classByteBuffer- See Also:
ByteBuffer.getFloat()
-
putFloat
public ByteBuffer putFloat(float value)
- Specified by:
putFloatin classByteBuffer- See Also:
ByteBuffer.putFloat(float)
-
getFloat
public float getFloat(int index)
- Specified by:
getFloatin classByteBuffer- See Also:
ByteBuffer.getFloat(int)
-
putFloat
public ByteBuffer putFloat(int index, float value)
- Specified by:
putFloatin classByteBuffer- See Also:
ByteBuffer.putFloat(int, float)
-
asFloatBuffer
public java.nio.FloatBuffer asFloatBuffer()
- Specified by:
asFloatBufferin classByteBuffer- See Also:
ByteBuffer.asFloatBuffer()
-
getDouble
public double getDouble()
- Specified by:
getDoublein classByteBuffer- See Also:
ByteBuffer.getDouble()
-
putDouble
public ByteBuffer putDouble(double value)
- Specified by:
putDoublein classByteBuffer- See Also:
ByteBuffer.putDouble(double)
-
getDouble
public double getDouble(int index)
- Specified by:
getDoublein classByteBuffer- See Also:
ByteBuffer.getDouble(int)
-
putDouble
public ByteBuffer putDouble(int index, double value)
- Specified by:
putDoublein classByteBuffer- See Also:
ByteBuffer.putDouble(int, double)
-
asDoubleBuffer
public java.nio.DoubleBuffer asDoubleBuffer()
- Specified by:
asDoubleBufferin classByteBuffer- See Also:
ByteBuffer.asDoubleBuffer()
-
getHexDump
public java.lang.String getHexDump()
Description copied from class:ByteBufferReturns hexdump of this buffer.- Overrides:
getHexDumpin classByteBuffer
-
getString
public java.lang.String getString(int fieldSize, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingExceptionDescription copied from class:ByteBufferReads aNUL-terminated string from this buffer using the specifieddecoderand returns it.- Overrides:
getStringin 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.CharacterCodingExceptionDescription copied from class:ByteBufferReads aNUL-terminated string from this buffer using the specifieddecoderand returns it. This method reads until the limit of this buffer if no NUL is found.- Overrides:
getStringin classByteBuffer- Throws:
java.nio.charset.CharacterCodingException
-
getPrefixedString
public java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingExceptionDescription copied from class:ByteBufferReads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoderand returns it. This method is a shortcut for getPrefixedString(2, decoder).- Overrides:
getPrefixedStringin classByteBuffer- Throws:
java.nio.charset.CharacterCodingException
-
getPrefixedString
public java.lang.String getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingExceptionDescription copied from class:ByteBufferReads a string which has a length field before the actual encoded string, using the specifieddecoderand returns it.- Overrides:
getPrefixedStringin 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:ByteBufferWrites the content ofininto 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 twoNULs as a terminator.Please note that this method doesn't terminate with
NULif the input string is longer than fieldSize.- Overrides:
putStringin classByteBufferfieldSize- 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:ByteBufferWrites the content ofininto this buffer using the specifiedencoder. This method doesn't terminate string with NUL. You have to do it by yourself.- Overrides:
putStringin 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:ByteBufferWrites the content ofininto 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:
putPrefixedStringin 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:ByteBufferWrites the content ofininto 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:
putPrefixedStringin classByteBufferprefixLength- 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:ByteBufferWrites the content ofininto 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:
putPrefixedStringin classByteBufferprefixLength- 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:ByteBufferWrites the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.- Overrides:
putPrefixedStringin classByteBufferprefixLength- 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:ByteBufferForwards the position of this buffer as the specifiedsizebytes.- Overrides:
skipin classByteBuffer
-
fill
public ByteBuffer fill(byte value, int size)
Description copied from class:ByteBufferFills this buffer with the specified value. This method moves buffer position forward.- Overrides:
fillin classByteBuffer
-
fillAndReset
public ByteBuffer fillAndReset(byte value, int size)
Description copied from class:ByteBufferFills this buffer with the specified value. This method does not change buffer position.- Overrides:
fillAndResetin classByteBuffer
-
fill
public ByteBuffer fill(int size)
Description copied from class:ByteBufferFills this buffer withNUL (0x00). This method moves buffer position forward.- Overrides:
fillin classByteBuffer
-
fillAndReset
public ByteBuffer fillAndReset(int size)
Description copied from class:ByteBufferFills this buffer withNUL (0x00). This method does not change buffer position.- Overrides:
fillAndResetin classByteBuffer
-
isAutoExpand
public boolean isAutoExpand()
Description copied from class:ByteBufferReturns true if and only if autoExpand is turned on.- Specified by:
isAutoExpandin classByteBuffer
-
setAutoExpand
public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class:ByteBufferTurns on or off autoExpand.- Specified by:
setAutoExpandin classByteBuffer
-
expand
public ByteBuffer expand(int pos, int expectedRemaining)
Description copied from class:ByteBufferChanges 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:
expandin classByteBuffer
-
expand
public ByteBuffer expand(int expectedRemaining)
Description copied from class:ByteBufferChanges 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:
expandin classByteBuffer
-
isPooled
public boolean isPooled()
Description copied from class:ByteBufferReturns 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:
isPooledin classByteBuffer
-
setPooled
public void setPooled(boolean pooled)
Description copied from class:ByteBufferSets 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:
setPooledin classByteBuffer
-
getObject
public java.lang.Object getObject() throws java.lang.ClassNotFoundExceptionDescription copied from class:ByteBufferReads a Java object from the buffer using the contextClassLoaderof the current thread.- Overrides:
getObjectin classByteBuffer- Throws:
java.lang.ClassNotFoundException
-
getObject
public java.lang.Object getObject(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundExceptionDescription copied from class:ByteBufferReads a Java object from the buffer using the specified classLoader.- Overrides:
getObjectin classByteBuffer- Throws:
java.lang.ClassNotFoundException
-
putObject
public ByteBuffer putObject(java.lang.Object o)
Description copied from class:ByteBufferWrites the specified Java object to the buffer.- Overrides:
putObjectin classByteBuffer
-
asInputStream
public java.io.InputStream asInputStream()
Description copied from class:ByteBufferReturns anInputStreamthat reads the data from this buffer.InputStream.read()returns -1 if the buffer position reaches to the limit.- Overrides:
asInputStreamin classByteBuffer
-
asOutputStream
public java.io.OutputStream asOutputStream()
Description copied from class:ByteBufferReturns anOutputStreamthat appends the data into this buffer. Please note that theOutputStream.write(int)will throw aBufferOverflowExceptioninstead of anIOExceptionin case of buffer overflow. Please set autoExpand property by callingByteBuffer.setAutoExpand(boolean)to prevent the unexpected runtime exception.- Overrides:
asOutputStreamin classByteBuffer
-
duplicate
public ByteBuffer duplicate()
- Specified by:
duplicatein classByteBuffer- See Also:
ByteBuffer.duplicate()
-
slice
public ByteBuffer slice()
- Specified by:
slicein classByteBuffer- See Also:
ByteBuffer.slice()
-
asReadOnlyBuffer
public ByteBuffer asReadOnlyBuffer()
- Specified by:
asReadOnlyBufferin classByteBuffer- See Also:
ByteBuffer.asReadOnlyBuffer()
-
array
public byte[] array()
- Specified by:
arrayin classByteBuffer- See Also:
ByteBuffer.array()
-
arrayOffset
public int arrayOffset()
- Specified by:
arrayOffsetin classByteBuffer- See Also:
ByteBuffer.arrayOffset()
-
capacity
public ByteBuffer capacity(int newCapacity)
Description copied from class:ByteBufferChanges the capacity of this buffer.- Specified by:
capacityin classByteBuffer
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin classByteBuffer- See Also:
Buffer.isReadOnly()
-
markValue
public int markValue()
Description copied from class:ByteBufferReturns the position of the current mark. This method returns -1 if no mark is set.- Specified by:
markValuein classByteBuffer
-
-