public class ByteBufferProxy extends ByteBuffer
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.
| 限定符和类型 | 字段和说明 |
|---|---|
protected ByteBuffer |
buf
The buffer proxied by this proxy.
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
ByteBufferProxy(ByteBuffer buf)
Create a new instance.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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 an
InputStream that reads the data from this buffer. |
java.nio.IntBuffer |
asIntBuffer() |
java.nio.LongBuffer |
asLongBuffer() |
java.io.OutputStream |
asOutputStream()
Returns an
OutputStream 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 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) |
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 context
ClassLoader
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(java.nio.charset.CharsetDecoder decoder)
Reads a string which has a 16-bit length field before the actual
encoded string, using the specified
decoder and returns it. |
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 specified
decoder and returns it. |
short |
getShort() |
short |
getShort(int index) |
java.lang.String |
getString(java.nio.charset.CharsetDecoder decoder)
Reads a
NUL-terminated string from this buffer using the
specified decoder and returns it. |
java.lang.String |
getString(int fieldSize,
java.nio.charset.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.
|
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(ByteBuffer src)
Writes the content of the specified src into this buffer.
|
ByteBuffer |
put(java.nio.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(java.lang.Object o)
Writes the specified Java object to the buffer.
|
ByteBuffer |
putPrefixedString(java.lang.CharSequence in,
java.nio.charset.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(java.lang.CharSequence in,
int prefixLength,
java.nio.charset.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(java.lang.CharSequence in,
int prefixLength,
int padding,
byte padValue,
java.nio.charset.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(java.lang.CharSequence in,
int prefixLength,
int padding,
java.nio.charset.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(java.lang.CharSequence in,
java.nio.charset.CharsetEncoder encoder)
Writes the content of
in into this buffer using the
specified encoder. |
ByteBuffer |
putString(java.lang.CharSequence in,
int fieldSize,
java.nio.charset.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.
|
java.lang.String |
toString() |
allocate, allocate, autoExpand, autoExpand, getAllocator, isUseDirectBuffers, prefixedDataAvailable, prefixedDataAvailable, setAllocator, setUseDirectBuffers, wrap, wrap, wrapprotected ByteBuffer buf
protected ByteBufferProxy(ByteBuffer buf)
buf - the buffer to be proxiedpublic void acquire()
ByteBufferByteBuffer.release() as many
as you invoked this method to release this buffer.acquire 在类中 ByteBufferpublic void release()
ByteBufferrelease 在类中 ByteBufferpublic boolean isDirect()
isDirect 在类中 ByteBufferByteBuffer.isDirect()public java.nio.ByteBuffer buf()
ByteBufferbuf 在类中 ByteBufferpublic int capacity()
capacity 在类中 ByteBufferBuffer.capacity()public int position()
position 在类中 ByteBufferBuffer.position()public ByteBuffer position(int newPosition)
position 在类中 ByteBufferBuffer.position(int)public int limit()
limit 在类中 ByteBufferBuffer.limit()public ByteBuffer limit(int newLimit)
limit 在类中 ByteBufferBuffer.limit(int)public ByteBuffer mark()
mark 在类中 ByteBufferBuffer.mark()public ByteBuffer reset()
reset 在类中 ByteBufferBuffer.reset()public ByteBuffer clear()
clear 在类中 ByteBufferBuffer.clear()public ByteBuffer sweep()
ByteBuffersweep 在类中 ByteBufferpublic ByteBuffer sweep(byte value)
ByteBuffersweep 在类中 ByteBufferpublic ByteBuffer flip()
flip 在类中 ByteBufferBuffer.flip()public ByteBuffer rewind()
rewind 在类中 ByteBufferBuffer.rewind()public int remaining()
remaining 在类中 ByteBufferBuffer.remaining()public boolean hasRemaining()
hasRemaining 在类中 ByteBufferBuffer.hasRemaining()public byte get()
get 在类中 ByteBufferByteBuffer.get()public short getUnsigned()
ByteBuffergetUnsigned 在类中 ByteBufferpublic ByteBuffer put(byte b)
put 在类中 ByteBufferByteBuffer.put(byte)public byte get(int index)
get 在类中 ByteBufferByteBuffer.get(int)public short getUnsigned(int index)
ByteBuffergetUnsigned 在类中 ByteBufferpublic ByteBuffer put(int index, byte b)
put 在类中 ByteBufferByteBuffer.put(int, byte)public ByteBuffer get(byte[] dst, int offset, int length)
get 在类中 ByteBufferByteBuffer.get(byte[], int, int)public ByteBuffer get(byte[] dst)
get 在类中 ByteBufferByteBuffer.get(byte[])public ByteBuffer put(ByteBuffer src)
ByteBufferput 在类中 ByteBufferpublic ByteBuffer put(java.nio.ByteBuffer src)
ByteBufferput 在类中 ByteBufferpublic ByteBuffer put(byte[] src, int offset, int length)
put 在类中 ByteBufferByteBuffer.put(byte[], int, int)public ByteBuffer put(byte[] src)
put 在类中 ByteBufferByteBuffer.put(byte[])public ByteBuffer compact()
compact 在类中 ByteBufferByteBuffer.compact()public java.lang.String toString()
toString 在类中 ByteBufferpublic int hashCode()
hashCode 在类中 ByteBufferpublic boolean equals(java.lang.Object ob)
equals 在类中 ByteBufferpublic int compareTo(ByteBuffer that)
compareTo 在接口中 java.lang.Comparable<ByteBuffer>compareTo 在类中 ByteBufferpublic java.nio.ByteOrder order()
order 在类中 ByteBufferByteBuffer.order()public ByteBuffer order(java.nio.ByteOrder bo)
order 在类中 ByteBufferByteBuffer.order(ByteOrder)public char getChar()
getChar 在类中 ByteBufferByteBuffer.getChar()public ByteBuffer putChar(char value)
putChar 在类中 ByteBufferByteBuffer.putChar(char)public char getChar(int index)
getChar 在类中 ByteBufferByteBuffer.getChar(int)public ByteBuffer putChar(int index, char value)
putChar 在类中 ByteBufferByteBuffer.putChar(int, char)public java.nio.CharBuffer asCharBuffer()
asCharBuffer 在类中 ByteBufferByteBuffer.asCharBuffer()public short getShort()
getShort 在类中 ByteBufferByteBuffer.getShort()public int getUnsignedShort()
ByteBuffergetUnsignedShort 在类中 ByteBufferpublic ByteBuffer putShort(short value)
putShort 在类中 ByteBufferByteBuffer.putShort(short)public short getShort(int index)
getShort 在类中 ByteBufferByteBuffer.getShort()public int getUnsignedShort(int index)
ByteBuffergetUnsignedShort 在类中 ByteBufferpublic ByteBuffer putShort(int index, short value)
putShort 在类中 ByteBufferByteBuffer.putShort(int, short)public java.nio.ShortBuffer asShortBuffer()
asShortBuffer 在类中 ByteBufferByteBuffer.asShortBuffer()public int getInt()
getInt 在类中 ByteBufferByteBuffer.getInt()public long getUnsignedInt()
ByteBuffergetUnsignedInt 在类中 ByteBufferpublic ByteBuffer putInt(int value)
putInt 在类中 ByteBufferByteBuffer.putInt(int)public int getInt(int index)
getInt 在类中 ByteBufferByteBuffer.getInt(int)public long getUnsignedInt(int index)
ByteBuffergetUnsignedInt 在类中 ByteBufferpublic ByteBuffer putInt(int index, int value)
putInt 在类中 ByteBufferByteBuffer.putInt(int, int)public java.nio.IntBuffer asIntBuffer()
asIntBuffer 在类中 ByteBufferByteBuffer.asIntBuffer()public long getLong()
getLong 在类中 ByteBufferByteBuffer.getLong()public ByteBuffer putLong(long value)
putLong 在类中 ByteBufferByteBuffer.putLong(int, long)public long getLong(int index)
getLong 在类中 ByteBufferByteBuffer.getLong(int)public ByteBuffer putLong(int index, long value)
putLong 在类中 ByteBufferByteBuffer.putLong(int, long)public java.nio.LongBuffer asLongBuffer()
asLongBuffer 在类中 ByteBufferByteBuffer.asLongBuffer()public float getFloat()
getFloat 在类中 ByteBufferByteBuffer.getFloat()public ByteBuffer putFloat(float value)
putFloat 在类中 ByteBufferByteBuffer.putFloat(float)public float getFloat(int index)
getFloat 在类中 ByteBufferByteBuffer.getFloat(int)public ByteBuffer putFloat(int index, float value)
putFloat 在类中 ByteBufferByteBuffer.putFloat(int, float)public java.nio.FloatBuffer asFloatBuffer()
asFloatBuffer 在类中 ByteBufferByteBuffer.asFloatBuffer()public double getDouble()
getDouble 在类中 ByteBufferByteBuffer.getDouble()public ByteBuffer putDouble(double value)
putDouble 在类中 ByteBufferByteBuffer.putDouble(double)public double getDouble(int index)
getDouble 在类中 ByteBufferByteBuffer.getDouble(int)public ByteBuffer putDouble(int index, double value)
putDouble 在类中 ByteBufferByteBuffer.putDouble(int, double)public java.nio.DoubleBuffer asDoubleBuffer()
asDoubleBuffer 在类中 ByteBufferByteBuffer.asDoubleBuffer()public java.lang.String getHexDump()
ByteBuffergetHexDump 在类中 ByteBufferpublic java.lang.String getString(int fieldSize,
java.nio.charset.CharsetDecoder decoder)
throws java.nio.charset.CharacterCodingException
ByteBufferNUL-terminated string from this buffer using the
specified decoder and returns it.getString 在类中 ByteBufferfieldSize - the maximum number of bytes to readjava.nio.charset.CharacterCodingExceptionpublic java.lang.String getString(java.nio.charset.CharsetDecoder decoder)
throws java.nio.charset.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 在类中 ByteBufferjava.nio.charset.CharacterCodingExceptionpublic java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder)
throws java.nio.charset.CharacterCodingException
ByteBufferdecoder and returns it.
This method is a shortcut for getPrefixedString(2, decoder).getPrefixedString 在类中 ByteBufferjava.nio.charset.CharacterCodingExceptionpublic java.lang.String getPrefixedString(int prefixLength,
java.nio.charset.CharsetDecoder decoder)
throws java.nio.charset.CharacterCodingException
ByteBufferdecoder and returns it.getPrefixedString 在类中 ByteBufferprefixLength - the length of the length field (1, 2, or 4)java.nio.charset.CharacterCodingExceptionpublic ByteBuffer putString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 ByteBufferfieldSize - the maximum number of bytes to writejava.nio.charset.CharacterCodingExceptionpublic ByteBuffer putString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 ByteBufferjava.nio.charset.CharacterCodingExceptionpublic ByteBuffer putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 ByteBufferjava.nio.charset.CharacterCodingExceptionpublic ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 ByteBufferprefixLength - the length of the length field (1, 2, or 4)java.nio.charset.CharacterCodingExceptionpublic ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 ByteBufferprefixLength - the length of the length field (1, 2, or 4)padding - the number of padded NULs (1 (or 0), 2, or 4)java.nio.charset.CharacterCodingExceptionpublic ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.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 在类中 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 bytesjava.nio.charset.CharacterCodingExceptionpublic ByteBuffer skip(int size)
ByteBuffersize
bytes.skip 在类中 ByteBufferpublic ByteBuffer fill(byte value, int size)
ByteBufferfill 在类中 ByteBufferpublic ByteBuffer fillAndReset(byte value, int size)
ByteBufferfillAndReset 在类中 ByteBufferpublic ByteBuffer fill(int size)
ByteBufferNUL (0x00).
This method moves buffer position forward.fill 在类中 ByteBufferpublic ByteBuffer fillAndReset(int size)
ByteBufferNUL (0x00).
This method does not change buffer position.fillAndReset 在类中 ByteBufferpublic boolean isAutoExpand()
ByteBufferisAutoExpand 在类中 ByteBufferpublic ByteBuffer setAutoExpand(boolean autoExpand)
ByteBuffersetAutoExpand 在类中 ByteBufferpublic ByteBuffer expand(int pos, int expectedRemaining)
ByteBufferexpand 在类中 ByteBufferpublic ByteBuffer expand(int expectedRemaining)
ByteBufferexpand 在类中 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 在类中 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 在类中 ByteBufferpublic java.lang.Object getObject()
throws java.lang.ClassNotFoundException
ByteBufferClassLoader
of the current thread.getObject 在类中 ByteBufferjava.lang.ClassNotFoundExceptionpublic java.lang.Object getObject(java.lang.ClassLoader classLoader)
throws java.lang.ClassNotFoundException
ByteBuffergetObject 在类中 ByteBufferjava.lang.ClassNotFoundExceptionpublic ByteBuffer putObject(java.lang.Object o)
ByteBufferputObject 在类中 ByteBufferpublic java.io.InputStream asInputStream()
ByteBufferInputStream that reads the data from this buffer.
InputStream.read() returns -1 if the buffer position
reaches to the limit.asInputStream 在类中 ByteBufferpublic java.io.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 在类中 ByteBufferpublic ByteBuffer duplicate()
duplicate 在类中 ByteBufferByteBuffer.duplicate()public ByteBuffer slice()
slice 在类中 ByteBufferByteBuffer.slice()public ByteBuffer asReadOnlyBuffer()
asReadOnlyBuffer 在类中 ByteBufferByteBuffer.asReadOnlyBuffer()public byte[] array()
array 在类中 ByteBufferByteBuffer.array()public int arrayOffset()
arrayOffset 在类中 ByteBufferByteBuffer.arrayOffset()public ByteBuffer capacity(int newCapacity)
ByteBuffercapacity 在类中 ByteBufferpublic boolean isReadOnly()
isReadOnly 在类中 ByteBufferBuffer.isReadOnly()public int markValue()
ByteBuffermarkValue 在类中 ByteBuffer