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, wrap
protected ByteBuffer buf
protected ByteBufferProxy(ByteBuffer buf)
buf
- the buffer to be proxiedpublic void acquire()
ByteBuffer
ByteBuffer.release()
as many
as you invoked this method to release this buffer.acquire
在类中 ByteBuffer
public void release()
ByteBuffer
release
在类中 ByteBuffer
public boolean isDirect()
isDirect
在类中 ByteBuffer
ByteBuffer.isDirect()
public java.nio.ByteBuffer buf()
ByteBuffer
buf
在类中 ByteBuffer
public int capacity()
capacity
在类中 ByteBuffer
Buffer.capacity()
public int position()
position
在类中 ByteBuffer
Buffer.position()
public ByteBuffer position(int newPosition)
position
在类中 ByteBuffer
Buffer.position(int)
public int limit()
limit
在类中 ByteBuffer
Buffer.limit()
public ByteBuffer limit(int newLimit)
limit
在类中 ByteBuffer
Buffer.limit(int)
public ByteBuffer mark()
mark
在类中 ByteBuffer
Buffer.mark()
public ByteBuffer reset()
reset
在类中 ByteBuffer
Buffer.reset()
public ByteBuffer clear()
clear
在类中 ByteBuffer
Buffer.clear()
public ByteBuffer sweep()
ByteBuffer
sweep
在类中 ByteBuffer
public ByteBuffer sweep(byte value)
ByteBuffer
sweep
在类中 ByteBuffer
public ByteBuffer flip()
flip
在类中 ByteBuffer
Buffer.flip()
public ByteBuffer rewind()
rewind
在类中 ByteBuffer
Buffer.rewind()
public int remaining()
remaining
在类中 ByteBuffer
Buffer.remaining()
public boolean hasRemaining()
hasRemaining
在类中 ByteBuffer
Buffer.hasRemaining()
public byte get()
get
在类中 ByteBuffer
ByteBuffer.get()
public short getUnsigned()
ByteBuffer
getUnsigned
在类中 ByteBuffer
public ByteBuffer put(byte b)
put
在类中 ByteBuffer
ByteBuffer.put(byte)
public byte get(int index)
get
在类中 ByteBuffer
ByteBuffer.get(int)
public short getUnsigned(int index)
ByteBuffer
getUnsigned
在类中 ByteBuffer
public ByteBuffer put(int index, byte b)
put
在类中 ByteBuffer
ByteBuffer.put(int, byte)
public ByteBuffer get(byte[] dst, int offset, int length)
get
在类中 ByteBuffer
ByteBuffer.get(byte[], int, int)
public ByteBuffer get(byte[] dst)
get
在类中 ByteBuffer
ByteBuffer.get(byte[])
public ByteBuffer put(ByteBuffer src)
ByteBuffer
put
在类中 ByteBuffer
public ByteBuffer put(java.nio.ByteBuffer src)
ByteBuffer
put
在类中 ByteBuffer
public ByteBuffer put(byte[] src, int offset, int length)
put
在类中 ByteBuffer
ByteBuffer.put(byte[], int, int)
public ByteBuffer put(byte[] src)
put
在类中 ByteBuffer
ByteBuffer.put(byte[])
public ByteBuffer compact()
compact
在类中 ByteBuffer
ByteBuffer.compact()
public java.lang.String toString()
toString
在类中 ByteBuffer
public int hashCode()
hashCode
在类中 ByteBuffer
public boolean equals(java.lang.Object ob)
equals
在类中 ByteBuffer
public int compareTo(ByteBuffer that)
compareTo
在接口中 java.lang.Comparable<ByteBuffer>
compareTo
在类中 ByteBuffer
public java.nio.ByteOrder order()
order
在类中 ByteBuffer
ByteBuffer.order()
public ByteBuffer order(java.nio.ByteOrder bo)
order
在类中 ByteBuffer
ByteBuffer.order(ByteOrder)
public char getChar()
getChar
在类中 ByteBuffer
ByteBuffer.getChar()
public ByteBuffer putChar(char value)
putChar
在类中 ByteBuffer
ByteBuffer.putChar(char)
public char getChar(int index)
getChar
在类中 ByteBuffer
ByteBuffer.getChar(int)
public ByteBuffer putChar(int index, char value)
putChar
在类中 ByteBuffer
ByteBuffer.putChar(int, char)
public java.nio.CharBuffer asCharBuffer()
asCharBuffer
在类中 ByteBuffer
ByteBuffer.asCharBuffer()
public short getShort()
getShort
在类中 ByteBuffer
ByteBuffer.getShort()
public int getUnsignedShort()
ByteBuffer
getUnsignedShort
在类中 ByteBuffer
public ByteBuffer putShort(short value)
putShort
在类中 ByteBuffer
ByteBuffer.putShort(short)
public short getShort(int index)
getShort
在类中 ByteBuffer
ByteBuffer.getShort()
public int getUnsignedShort(int index)
ByteBuffer
getUnsignedShort
在类中 ByteBuffer
public ByteBuffer putShort(int index, short value)
putShort
在类中 ByteBuffer
ByteBuffer.putShort(int, short)
public java.nio.ShortBuffer asShortBuffer()
asShortBuffer
在类中 ByteBuffer
ByteBuffer.asShortBuffer()
public int getInt()
getInt
在类中 ByteBuffer
ByteBuffer.getInt()
public long getUnsignedInt()
ByteBuffer
getUnsignedInt
在类中 ByteBuffer
public ByteBuffer putInt(int value)
putInt
在类中 ByteBuffer
ByteBuffer.putInt(int)
public int getInt(int index)
getInt
在类中 ByteBuffer
ByteBuffer.getInt(int)
public long getUnsignedInt(int index)
ByteBuffer
getUnsignedInt
在类中 ByteBuffer
public ByteBuffer putInt(int index, int value)
putInt
在类中 ByteBuffer
ByteBuffer.putInt(int, int)
public java.nio.IntBuffer asIntBuffer()
asIntBuffer
在类中 ByteBuffer
ByteBuffer.asIntBuffer()
public long getLong()
getLong
在类中 ByteBuffer
ByteBuffer.getLong()
public ByteBuffer putLong(long value)
putLong
在类中 ByteBuffer
ByteBuffer.putLong(int, long)
public long getLong(int index)
getLong
在类中 ByteBuffer
ByteBuffer.getLong(int)
public ByteBuffer putLong(int index, long value)
putLong
在类中 ByteBuffer
ByteBuffer.putLong(int, long)
public java.nio.LongBuffer asLongBuffer()
asLongBuffer
在类中 ByteBuffer
ByteBuffer.asLongBuffer()
public float getFloat()
getFloat
在类中 ByteBuffer
ByteBuffer.getFloat()
public ByteBuffer putFloat(float value)
putFloat
在类中 ByteBuffer
ByteBuffer.putFloat(float)
public float getFloat(int index)
getFloat
在类中 ByteBuffer
ByteBuffer.getFloat(int)
public ByteBuffer putFloat(int index, float value)
putFloat
在类中 ByteBuffer
ByteBuffer.putFloat(int, float)
public java.nio.FloatBuffer asFloatBuffer()
asFloatBuffer
在类中 ByteBuffer
ByteBuffer.asFloatBuffer()
public double getDouble()
getDouble
在类中 ByteBuffer
ByteBuffer.getDouble()
public ByteBuffer putDouble(double value)
putDouble
在类中 ByteBuffer
ByteBuffer.putDouble(double)
public double getDouble(int index)
getDouble
在类中 ByteBuffer
ByteBuffer.getDouble(int)
public ByteBuffer putDouble(int index, double value)
putDouble
在类中 ByteBuffer
ByteBuffer.putDouble(int, double)
public java.nio.DoubleBuffer asDoubleBuffer()
asDoubleBuffer
在类中 ByteBuffer
ByteBuffer.asDoubleBuffer()
public java.lang.String getHexDump()
ByteBuffer
getHexDump
在类中 ByteBuffer
public java.lang.String getString(int fieldSize, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
NUL
-terminated string from this buffer using the
specified decoder
and returns it.getString
在类中 ByteBuffer
fieldSize
- the maximum number of bytes to readjava.nio.charset.CharacterCodingException
public java.lang.String getString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
NUL
-terminated string from this buffer using the
specified decoder
and returns it. This method reads
until the limit of this buffer if no NUL is found.getString
在类中 ByteBuffer
java.nio.charset.CharacterCodingException
public java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
decoder
and returns it.
This method is a shortcut for getPrefixedString(2, decoder).getPrefixedString
在类中 ByteBuffer
java.nio.charset.CharacterCodingException
public java.lang.String getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
decoder
and returns it.getPrefixedString
在类中 ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)java.nio.charset.CharacterCodingException
public ByteBuffer putString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer as a
NUL
-terminated string using the specified
encoder
.
If the charset name of the encoder is UTF-16, you cannot specify
odd fieldSize
, and this method will append two
NUL
s as a terminator.
Please note that this method doesn't terminate with NUL
if the input string is longer than fieldSize.
putString
在类中 ByteBuffer
fieldSize
- the maximum number of bytes to writejava.nio.charset.CharacterCodingException
public ByteBuffer putString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer using the
specified encoder
. This method doesn't terminate
string with NUL. You have to do it by yourself.putString
在类中 ByteBuffer
java.nio.charset.CharacterCodingException
public ByteBuffer putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, 2, 0, encoder).putPrefixedString
在类中 ByteBuffer
java.nio.charset.CharacterCodingException
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, prefixLength, 0, encoder).putPrefixedString
在类中 ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)java.nio.charset.CharacterCodingException
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.
This method is a shortcut for putPrefixedString(in, prefixLength, padding, ( byte ) 0, encoder).putPrefixedString
在类中 ByteBuffer
prefixLength
- 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.CharacterCodingException
public ByteBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
ByteBuffer
in
into this buffer as a
string which has a 16-bit length field before the actual
encoded string, using the specified encoder
.putPrefixedString
在类中 ByteBuffer
prefixLength
- the length of the length field (1, 2, or 4)padding
- the number of padded bytes (1 (or 0), 2, or 4)padValue
- the value of padded bytesjava.nio.charset.CharacterCodingException
public ByteBuffer skip(int size)
ByteBuffer
size
bytes.skip
在类中 ByteBuffer
public ByteBuffer fill(byte value, int size)
ByteBuffer
fill
在类中 ByteBuffer
public ByteBuffer fillAndReset(byte value, int size)
ByteBuffer
fillAndReset
在类中 ByteBuffer
public ByteBuffer fill(int size)
ByteBuffer
NUL (0x00)
.
This method moves buffer position forward.fill
在类中 ByteBuffer
public ByteBuffer fillAndReset(int size)
ByteBuffer
NUL (0x00)
.
This method does not change buffer position.fillAndReset
在类中 ByteBuffer
public boolean isAutoExpand()
ByteBuffer
isAutoExpand
在类中 ByteBuffer
public ByteBuffer setAutoExpand(boolean autoExpand)
ByteBuffer
setAutoExpand
在类中 ByteBuffer
public ByteBuffer expand(int pos, int expectedRemaining)
ByteBuffer
expand
在类中 ByteBuffer
public ByteBuffer expand(int expectedRemaining)
ByteBuffer
expand
在类中 ByteBuffer
public 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
在类中 ByteBuffer
public 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
在类中 ByteBuffer
public java.lang.Object getObject() throws java.lang.ClassNotFoundException
ByteBuffer
ClassLoader
of the current thread.getObject
在类中 ByteBuffer
java.lang.ClassNotFoundException
public java.lang.Object getObject(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
ByteBuffer
getObject
在类中 ByteBuffer
java.lang.ClassNotFoundException
public ByteBuffer putObject(java.lang.Object o)
ByteBuffer
putObject
在类中 ByteBuffer
public java.io.InputStream asInputStream()
ByteBuffer
InputStream
that reads the data from this buffer.
InputStream.read()
returns -1 if the buffer position
reaches to the limit.asInputStream
在类中 ByteBuffer
public java.io.OutputStream asOutputStream()
ByteBuffer
OutputStream
that appends the data into this buffer.
Please note that the OutputStream.write(int)
will throw a
BufferOverflowException
instead of an IOException
in case of buffer overflow. Please set autoExpand property by
calling ByteBuffer.setAutoExpand(boolean)
to prevent the unexpected runtime
exception.asOutputStream
在类中 ByteBuffer
public ByteBuffer duplicate()
duplicate
在类中 ByteBuffer
ByteBuffer.duplicate()
public ByteBuffer slice()
slice
在类中 ByteBuffer
ByteBuffer.slice()
public ByteBuffer asReadOnlyBuffer()
asReadOnlyBuffer
在类中 ByteBuffer
ByteBuffer.asReadOnlyBuffer()
public byte[] array()
array
在类中 ByteBuffer
ByteBuffer.array()
public int arrayOffset()
arrayOffset
在类中 ByteBuffer
ByteBuffer.arrayOffset()
public ByteBuffer capacity(int newCapacity)
ByteBuffer
capacity
在类中 ByteBuffer
public boolean isReadOnly()
isReadOnly
在类中 ByteBuffer
Buffer.isReadOnly()
public int markValue()
ByteBuffer
markValue
在类中 ByteBuffer