public class IoBufferWrapper extends IoBuffer
IoBuffer
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 |
IoBufferWrapper(IoBuffer buf)
Create a new instance.
|
限定符和类型 | 方法和说明 |
---|---|
byte[] |
array() |
int |
arrayOffset() |
java.nio.CharBuffer |
asCharBuffer() |
java.nio.DoubleBuffer |
asDoubleBuffer() |
java.nio.FloatBuffer |
asFloatBuffer() |
java.io.InputStream |
asInputStream() |
java.nio.IntBuffer |
asIntBuffer() |
java.nio.LongBuffer |
asLongBuffer() |
java.io.OutputStream |
asOutputStream() |
IoBuffer |
asReadOnlyBuffer() |
java.nio.ShortBuffer |
asShortBuffer() |
java.nio.ByteBuffer |
buf() |
int |
capacity() |
IoBuffer |
capacity(int newCapacity)
Increases the capacity of this buffer.
|
IoBuffer |
clear() |
IoBuffer |
compact() |
int |
compareTo(IoBuffer that) |
IoBuffer |
duplicate() |
boolean |
equals(java.lang.Object ob) |
IoBuffer |
expand(int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get the
specified expectedRemaining room from the current position.
|
IoBuffer |
expand(int pos,
int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get the
specified expectedRemaining room from the specified
position.
|
IoBuffer |
fill(byte value,
int size)
Fills this buffer with the specified value.
|
IoBuffer |
fill(int size)
Fills this buffer with
NUL (0x00) . |
IoBuffer |
fillAndReset(byte value,
int size)
Fills this buffer with the specified value.
|
IoBuffer |
fillAndReset(int size)
Fills this buffer with
NUL (0x00) . |
IoBuffer |
flip() |
void |
free()
Declares this buffer and all its derived buffers are not used anymore so
that it can be reused by some
IoBufferAllocator implementations. |
byte |
get() |
IoBuffer |
get(byte[] dst) |
IoBuffer |
get(byte[] dst,
int offset,
int length) |
byte |
get(int index) |
char |
getChar() |
char |
getChar(int index) |
double |
getDouble() |
double |
getDouble(int index) |
<E extends java.lang.Enum<E>> |
getEnum(java.lang.Class<E> enumClass)
Reads a byte from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
<E extends java.lang.Enum<E>> |
getEnum(int index,
java.lang.Class<E> enumClass)
Reads a byte from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
<E extends java.lang.Enum<E>> |
getEnumInt(java.lang.Class<E> enumClass)
Reads an int from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
<E extends java.lang.Enum<E>> |
getEnumInt(int index,
java.lang.Class<E> enumClass)
Reads an int from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
<E extends java.lang.Enum<E>> |
getEnumSet(java.lang.Class<E> enumClass)
Reads a byte sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSet(int index,
java.lang.Class<E> enumClass)
Reads a byte sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetInt(java.lang.Class<E> enumClass)
Reads an int sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetInt(int index,
java.lang.Class<E> enumClass)
Reads an int sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetLong(java.lang.Class<E> enumClass)
Reads a long sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetLong(int index,
java.lang.Class<E> enumClass)
Reads a long sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetShort(java.lang.Class<E> enumClass)
Reads a short sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumSetShort(int index,
java.lang.Class<E> enumClass)
Reads a short sized bit vector and converts it to an
EnumSet . |
<E extends java.lang.Enum<E>> |
getEnumShort(java.lang.Class<E> enumClass)
Reads a short from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
<E extends java.lang.Enum<E>> |
getEnumShort(int index,
java.lang.Class<E> enumClass)
Reads a short from the buffer and returns the correlating enum constant
defined by the specified enum type.
|
float |
getFloat() |
float |
getFloat(int index) |
java.lang.String |
getHexDump()
Returns hexdump of this buffer.
|
java.lang.String |
getHexDump(int lengthLimit)
Return hexdump of this buffer with limited length.
|
int |
getInt() |
int |
getInt(int index) |
long |
getLong() |
long |
getLong(int index) |
int |
getMediumInt()
Relative get method for reading a medium int value.
|
int |
getMediumInt(int index)
Absolute get method for reading a medium int value.
|
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.
|
IoBuffer |
getParentBuffer() |
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) |
IoBuffer |
getSlice(int length)
Get a new IoBuffer containing a slice of the current buffer
|
IoBuffer |
getSlice(int index,
int length)
Get a new IoBuffer containing a slice of the current buffer
|
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 |
getUnsignedMediumInt()
Relative get method for reading an unsigned medium int value.
|
int |
getUnsignedMediumInt(int index)
Absolute get method for reading an unsigned medium int value.
|
int |
getUnsignedShort()
Reads two bytes unsigned integer.
|
int |
getUnsignedShort(int index)
Reads two bytes unsigned integer.
|
boolean |
hasArray() |
int |
hashCode() |
boolean |
hasRemaining() |
int |
indexOf(byte b)
Returns the first occurrence position of the specified byte from the
current position to the current limit.
|
boolean |
isAutoExpand() |
boolean |
isAutoShrink() |
boolean |
isDerived() |
boolean |
isDirect() |
boolean |
isReadOnly() |
int |
limit() |
IoBuffer |
limit(int newLimit) |
IoBuffer |
mark() |
int |
markValue() |
int |
minimumCapacity() |
IoBuffer |
minimumCapacity(int minimumCapacity)
Sets the minimum capacity of this buffer which is used to determine the
new capacity of the buffer shrunk by
IoBuffer.compact() and
IoBuffer.shrink() operation. |
java.nio.ByteOrder |
order() |
IoBuffer |
order(java.nio.ByteOrder bo) |
int |
position() |
IoBuffer |
position(int newPosition) |
boolean |
prefixedDataAvailable(int prefixLength) |
boolean |
prefixedDataAvailable(int prefixLength,
int maxDataLength) |
IoBuffer |
put(byte b) |
IoBuffer |
put(byte[] src) |
IoBuffer |
put(byte[] src,
int offset,
int length) |
IoBuffer |
put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
|
IoBuffer |
put(int index,
byte b) |
IoBuffer |
put(IoBuffer src)
Writes the content of the specified src into this buffer.
|
IoBuffer |
putChar(char value) |
IoBuffer |
putChar(int index,
char value) |
IoBuffer |
putDouble(double value) |
IoBuffer |
putDouble(int index,
double value) |
IoBuffer |
putEnum(java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as a byte.
|
IoBuffer |
putEnum(int index,
java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as a byte.
|
IoBuffer |
putEnumInt(java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as an integer.
|
IoBuffer |
putEnumInt(int index,
java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as an integer.
|
<E extends java.lang.Enum<E>> |
putEnumSet(int index,
java.util.Set<E> set)
Writes the specified
Set to the buffer as a byte sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSet(java.util.Set<E> set)
Writes the specified
Set to the buffer as a byte sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetInt(int index,
java.util.Set<E> set)
Writes the specified
Set to the buffer as an int sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetInt(java.util.Set<E> set)
Writes the specified
Set to the buffer as an int sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetLong(int index,
java.util.Set<E> set)
Writes the specified
Set to the buffer as a long sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetLong(java.util.Set<E> set)
Writes the specified
Set to the buffer as a long sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetShort(int index,
java.util.Set<E> set)
Writes the specified
Set to the buffer as a short sized bit
vector. |
<E extends java.lang.Enum<E>> |
putEnumSetShort(java.util.Set<E> set)
Writes the specified
Set to the buffer as a short sized bit
vector. |
IoBuffer |
putEnumShort(java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as a short.
|
IoBuffer |
putEnumShort(int index,
java.lang.Enum<?> e)
Writes an enum's ordinal value to the buffer as a short.
|
IoBuffer |
putFloat(float value) |
IoBuffer |
putFloat(int index,
float value) |
IoBuffer |
putInt(int value) |
IoBuffer |
putInt(int index,
int value) |
IoBuffer |
putLong(int index,
long value) |
IoBuffer |
putLong(long value) |
IoBuffer |
putMediumInt(int value)
Relative put method for writing a medium int value.
|
IoBuffer |
putMediumInt(int index,
int value)
Absolute put method for writing a medium int value.
|
IoBuffer |
putObject(java.lang.Object o)
Writes the specified Java object to the buffer.
|
IoBuffer |
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 . |
IoBuffer |
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 . |
IoBuffer |
putPrefixedString(java.lang.CharSequence in,
int prefixLength,
int padding,
byte padValue,
java.nio.charset.CharsetEncoder encoder)
Writes the content of
val into this buffer as a string which
has a 16-bit length field before the actual encoded string, using the
specified encoder . |
IoBuffer |
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 . |
IoBuffer |
putShort(int index,
short value) |
IoBuffer |
putShort(short value) |
IoBuffer |
putString(java.lang.CharSequence in,
java.nio.charset.CharsetEncoder encoder)
Writes the content of
in into this buffer using the
specified encoder . |
IoBuffer |
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 . |
IoBuffer |
putUnsigned(byte value)
Writes an unsigned byte into the ByteBuffer
|
IoBuffer |
putUnsigned(int value)
Writes an unsigned byte into the ByteBuffer
|
IoBuffer |
putUnsigned(int index,
byte value)
Writes an unsigned byte into the ByteBuffer at a specified position
|
IoBuffer |
putUnsigned(int index,
int value)
Writes an unsigned byte into the ByteBuffer at a specified position
|
IoBuffer |
putUnsigned(int index,
long value)
Writes an unsigned byte into the ByteBuffer at a specified position
|
IoBuffer |
putUnsigned(int index,
short value)
Writes an unsigned byte into the ByteBuffer at a specified position
|
IoBuffer |
putUnsigned(long value)
Writes an unsigned byte into the ByteBuffer
|
IoBuffer |
putUnsigned(short value)
Writes an unsigned byte into the ByteBuffer
|
IoBuffer |
putUnsignedInt(byte value)
Writes an unsigned int into the ByteBuffer
|
IoBuffer |
putUnsignedInt(int value)
Writes an unsigned int into the ByteBuffer
|
IoBuffer |
putUnsignedInt(int index,
byte value)
Writes an unsigned int into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedInt(int index,
int value)
Writes an unsigned int into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedInt(int index,
long value)
Writes an unsigned int into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedInt(int index,
short value)
Writes an unsigned int into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedInt(long value)
Writes an unsigned int into the ByteBuffer
|
IoBuffer |
putUnsignedInt(short value)
Writes an unsigned int into the ByteBuffer
|
IoBuffer |
putUnsignedShort(byte value)
Writes an unsigned short into the ByteBuffer
|
IoBuffer |
putUnsignedShort(int value)
Writes an unsigned Short into the ByteBuffer
|
IoBuffer |
putUnsignedShort(int index,
byte value)
Writes an unsigned Short into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedShort(int index,
int value)
Writes an unsigned Short into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedShort(int index,
long value)
Writes an unsigned Short into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedShort(int index,
short value)
Writes an unsigned Short into the ByteBuffer at a specified position
|
IoBuffer |
putUnsignedShort(long value)
Writes an unsigned Short into the ByteBuffer
|
IoBuffer |
putUnsignedShort(short value)
Writes an unsigned Short into the ByteBuffer
|
int |
remaining() |
IoBuffer |
reset() |
IoBuffer |
rewind() |
IoBuffer |
setAutoExpand(boolean autoExpand)
Turns on or off autoExpand.
|
IoBuffer |
setAutoShrink(boolean autoShrink)
Turns on or off autoShrink.
|
IoBuffer |
shrink()
Changes the capacity of this buffer so this buffer occupies as less
memory as possible while retaining the position, limit and the buffer
content between the position and limit.
|
IoBuffer |
skip(int size)
Forwards the position of this buffer as the specified
size
bytes. |
IoBuffer |
slice() |
IoBuffer |
sweep()
Clears this buffer and fills its content with NUL.
|
IoBuffer |
sweep(byte value)
double Clears this buffer and fills its content with value.
|
java.lang.String |
toString() |
allocate, allocate, getAllocator, isUseDirectBuffer, normalizeCapacity, setAllocator, setUseDirectBuffer, wrap, wrap, wrap
protected IoBufferWrapper(IoBuffer buf)
buf
- the buffer to be proxiedpublic IoBuffer getParentBuffer()
public boolean isDirect()
public java.nio.ByteBuffer buf()
public int capacity()
public int position()
public IoBuffer position(int newPosition)
public int limit()
public IoBuffer limit(int newLimit)
public IoBuffer sweep()
IoBuffer
public IoBuffer sweep(byte value)
IoBuffer
public IoBuffer rewind()
public int remaining()
public boolean hasRemaining()
hasRemaining
在类中 IoBuffer
Buffer.hasRemaining()
public byte get()
public short getUnsigned()
IoBuffer
getUnsigned
在类中 IoBuffer
public IoBuffer put(byte b)
public byte get(int index)
public short getUnsigned(int index)
IoBuffer
getUnsigned
在类中 IoBuffer
index
- The position for which we want to read an unsigned bytepublic IoBuffer put(int index, byte b)
public IoBuffer get(byte[] dst, int offset, int length)
public IoBuffer getSlice(int index, int length)
IoBuffer
public IoBuffer getSlice(int length)
IoBuffer
public IoBuffer get(byte[] dst)
public IoBuffer put(IoBuffer src)
IoBuffer
public IoBuffer put(java.nio.ByteBuffer src)
IoBuffer
public IoBuffer put(byte[] src, int offset, int length)
public IoBuffer put(byte[] src)
public IoBuffer compact()
public java.lang.String toString()
toString
在类中 java.lang.Object
public int hashCode()
hashCode
在类中 java.lang.Object
public boolean equals(java.lang.Object ob)
equals
在类中 java.lang.Object
public int compareTo(IoBuffer that)
public java.nio.ByteOrder order()
public IoBuffer order(java.nio.ByteOrder bo)
public char getChar()
public IoBuffer putChar(char value)
public char getChar(int index)
public IoBuffer putChar(int index, char value)
public java.nio.CharBuffer asCharBuffer()
asCharBuffer
在类中 IoBuffer
ByteBuffer.asCharBuffer()
public short getShort()
public int getUnsignedShort()
IoBuffer
getUnsignedShort
在类中 IoBuffer
public IoBuffer putShort(short value)
public short getShort(int index)
public int getUnsignedShort(int index)
IoBuffer
getUnsignedShort
在类中 IoBuffer
index
- The index in the IoBuffer where we will read an unsigned short frompublic IoBuffer putShort(int index, short value)
public java.nio.ShortBuffer asShortBuffer()
asShortBuffer
在类中 IoBuffer
ByteBuffer.asShortBuffer()
public long getUnsignedInt()
IoBuffer
getUnsignedInt
在类中 IoBuffer
public IoBuffer putInt(int value)
public IoBuffer putUnsignedInt(byte value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
value
- the byte to writepublic IoBuffer putUnsignedInt(int index, byte value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the byte to writepublic IoBuffer putUnsignedInt(short value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
value
- the short to writepublic IoBuffer putUnsignedInt(int index, short value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the short to writepublic IoBuffer putUnsignedInt(int value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
value
- the int to writepublic IoBuffer putUnsignedInt(int index, int value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the int to writepublic IoBuffer putUnsignedInt(long value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
value
- the long to writepublic IoBuffer putUnsignedInt(int index, long value)
IoBuffer
putUnsignedInt
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the long to writepublic IoBuffer putUnsignedShort(byte value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
value
- the byte to writepublic IoBuffer putUnsignedShort(int index, byte value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the byte to writepublic IoBuffer putUnsignedShort(short value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
value
- the short to writepublic IoBuffer putUnsignedShort(int index, short value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
index
- the position in the buffer to write the unsigned shortvalue
- the unsigned short to writepublic IoBuffer putUnsignedShort(int value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
value
- the int to writepublic IoBuffer putUnsignedShort(int index, int value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the int to writepublic IoBuffer putUnsignedShort(long value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
value
- the long to writepublic IoBuffer putUnsignedShort(int index, long value)
IoBuffer
putUnsignedShort
在类中 IoBuffer
index
- the position in the buffer to write the shortvalue
- the long to writepublic int getInt(int index)
public long getUnsignedInt(int index)
IoBuffer
getUnsignedInt
在类中 IoBuffer
index
- The index in the IoBuffer where we will read an unsigned int frompublic IoBuffer putInt(int index, int value)
public java.nio.IntBuffer asIntBuffer()
asIntBuffer
在类中 IoBuffer
ByteBuffer.asIntBuffer()
public long getLong()
public IoBuffer putLong(long value)
public long getLong(int index)
public IoBuffer putLong(int index, long value)
public java.nio.LongBuffer asLongBuffer()
asLongBuffer
在类中 IoBuffer
ByteBuffer.asLongBuffer()
public float getFloat()
public IoBuffer putFloat(float value)
public float getFloat(int index)
public IoBuffer putFloat(int index, float value)
public java.nio.FloatBuffer asFloatBuffer()
asFloatBuffer
在类中 IoBuffer
ByteBuffer.asFloatBuffer()
public double getDouble()
public IoBuffer putDouble(double value)
public double getDouble(int index)
public IoBuffer putDouble(int index, double value)
public java.nio.DoubleBuffer asDoubleBuffer()
asDoubleBuffer
在类中 IoBuffer
ByteBuffer.asDoubleBuffer()
public java.lang.String getHexDump()
IoBuffer
getHexDump
在类中 IoBuffer
public java.lang.String getString(int fieldSize, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
IoBuffer
NUL
-terminated string from this buffer using the
specified decoder
and returns it.public java.lang.String getString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
IoBuffer
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.public java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
IoBuffer
decoder
and returns it. This
method is a shortcut for getPrefixedString(2, decoder).getPrefixedString
在类中 IoBuffer
decoder
- The CharsetDecoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the Stringpublic java.lang.String getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
IoBuffer
decoder
and returns it.getPrefixedString
在类中 IoBuffer
prefixLength
- the length of the length field (1, 2, or 4)decoder
- The CharsetDecoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the Stringpublic IoBuffer putString(java.lang.CharSequence in, int fieldSize, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
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.
public IoBuffer putString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
in
into this buffer using the
specified encoder
. This method doesn't terminate string with
NUL. You have to do it by yourself.public IoBuffer putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
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
在类中 IoBuffer
in
- The CharSequence to put in the IoBufferencoder
- The CharsetEncoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the CharSequencepublic IoBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
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
在类中 IoBuffer
in
- The CharSequence to put in the IoBufferprefixLength
- the length of the length field (1, 2, or 4)encoder
- The CharsetEncoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the CharSequencepublic IoBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
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
在类中 IoBuffer
in
- The CharSequence to put in the IoBufferprefixLength
- the length of the length field (1, 2, or 4)padding
- the number of padded NULs (1 (or 0), 2, or 4)encoder
- The CharsetEncoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the CharSequencepublic IoBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
IoBuffer
val
into this buffer as a string which
has a 16-bit length field before the actual encoded string, using the
specified encoder
.putPrefixedString
在类中 IoBuffer
in
- The CharSequence to put in teh IoBufferprefixLength
- 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 bytesencoder
- The CharsetEncoder to usejava.nio.charset.CharacterCodingException
- When we have an error while decoding the CharSequencepublic IoBuffer skip(int size)
IoBuffer
size
bytes.public IoBuffer fill(byte value, int size)
IoBuffer
public IoBuffer fillAndReset(byte value, int size)
IoBuffer
fillAndReset
在类中 IoBuffer
value
- The value to fill the IoBuffer withsize
- The added sizepublic IoBuffer fill(int size)
IoBuffer
NUL (0x00)
. This method moves buffer
position forward.public IoBuffer fillAndReset(int size)
IoBuffer
NUL (0x00)
. This method does not
change buffer position.fillAndReset
在类中 IoBuffer
size
- The added sizepublic boolean isAutoExpand()
isAutoExpand
在类中 IoBuffer
public IoBuffer setAutoExpand(boolean autoExpand)
IoBuffer
setAutoExpand
在类中 IoBuffer
autoExpand
- The flag value to setpublic IoBuffer expand(int pos, int expectedRemaining)
IoBuffer
Initial buffer : P L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit capacity ( pos + V ) <= L, no change : P L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit newCapacity You can still put ( L - pos ) bytes in the buffer ( pos + V ) > L & ( pos + V ) <= C : P L C +------------+------+ |XXXXXXXX:...| | +------------+------+ ^ ^ ^ | | | pos newlimit newCapacity You can now put ( L - pos + V) bytes in the buffer. ( pos + V ) > C P L C +-------------------+----+ |XXXXXXXX:..........:....| +------------------------+ ^ ^ | | pos +-- newlimit | +-- newCapacity You can now put ( L - pos + V ) bytes in the buffer, which limit is now equals to the capacity.Note that the expecting remaining bytes starts at the current position. In all those examples, the position is P.
public IoBuffer expand(int expectedRemaining)
IoBuffer
Initial buffer : 0 L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit capacity ( pos + V ) <= L, no change : 0 L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit newCapacity You can still put ( L - pos ) bytes in the buffer ( pos + V ) > L & ( pos + V ) <= C : 0 L C +------------+------+ |XXXXXXXX:...| | +------------+------+ ^ ^ ^ | | | pos newlimit newCapacity You can now put ( L - pos + V ) bytes in the buffer. ( pos + V ) > C 0 L C +-------------------+----+ |XXXXXXXX:..........:....| +------------------------+ ^ ^ | | pos +-- newlimit | +-- newCapacity You can now put ( L - pos + V ) bytes in the buffer, which limit is now equals to the capacity.Note that the expecting remaining bytes starts at the current position. In all those examples, the position is 0.
public java.lang.Object getObject() throws java.lang.ClassNotFoundException
IoBuffer
ClassLoader
of the current thread.public java.lang.Object getObject(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
IoBuffer
public IoBuffer putObject(java.lang.Object o)
IoBuffer
public java.io.InputStream asInputStream()
asInputStream
在类中 IoBuffer
InputStream
that reads the data from this buffer.
InputStream.read()
returns -1 if the buffer position
reaches to the limit.public java.io.OutputStream asOutputStream()
asOutputStream
在类中 IoBuffer
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
IoBuffer.setAutoExpand(boolean)
to prevent the unexpected runtime
exception.public IoBuffer duplicate()
public IoBuffer slice()
public IoBuffer asReadOnlyBuffer()
asReadOnlyBuffer
在类中 IoBuffer
ByteBuffer.asReadOnlyBuffer()
public byte[] array()
public int arrayOffset()
arrayOffset
在类中 IoBuffer
IoBuffer.array()
method is calledByteBuffer.arrayOffset()
public int minimumCapacity()
minimumCapacity
在类中 IoBuffer
IoBuffer.compact()
and
IoBuffer.shrink()
operation. The default value is the initial capacity of
the buffer.public IoBuffer minimumCapacity(int minimumCapacity)
IoBuffer
IoBuffer.compact()
and
IoBuffer.shrink()
operation. The default value is the initial capacity of
the buffer.minimumCapacity
在类中 IoBuffer
minimumCapacity
- the wanted minimum capacityByteBuffer
instance.public IoBuffer capacity(int newCapacity)
IoBuffer
Initial buffer : 0 L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit capacity V <= C : 0 L C +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ | | | pos limit newCapacity V > C : 0 L C V +--------+-----------------------+ |XXXXXXXX| : | +--------+-----------------------+ ^ ^ ^ ^ | | | | pos limit oldCapacity newCapacity The buffer has been increased.
public boolean isReadOnly()
isReadOnly
在类中 IoBuffer
Buffer.isReadOnly()
public int markValue()
public boolean hasArray()
hasArray
在类中 IoBuffer
IoBuffer.array()
method will return a byte[]ByteBuffer.hasArray()
public void free()
IoBuffer
IoBufferAllocator
implementations.
It is not mandatory to call this method, but you might want to invoke
this method for maximum performance.public boolean isDerived()
isDerived
在类中 IoBuffer
IoBuffer.duplicate()
, IoBuffer.slice()
or
IoBuffer.asReadOnlyBuffer()
methods.public boolean isAutoShrink()
isAutoShrink
在类中 IoBuffer
public IoBuffer setAutoShrink(boolean autoShrink)
IoBuffer
setAutoShrink
在类中 IoBuffer
autoShrink
- The flag value to setpublic IoBuffer shrink()
IoBuffer
IoBuffer.minimumCapacity()
IoBuffer.minimumCapacity()
. For instance, if
the limit is 7 and the capacity is 36, with a minimum capacity of 8,
shrinking the buffer will left a capacity of 9 (we go down from 36 to 18, then from 18 to 9).
Initial buffer : +--------+----------+ |XXXXXXXX| | +--------+----------+ ^ ^ ^ ^ | | | | pos | | capacity | | | +-- minimumCapacity | +-- limit Resulting buffer : +--------+--+-+ |XXXXXXXX| | | +--------+--+-+ ^ ^ ^ ^ | | | | | | | +-- new capacity | | | pos | +-- minimum capacity | +-- limit
public int getMediumInt()
IoBuffer
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by three.
getMediumInt
在类中 IoBuffer
public int getUnsignedMediumInt()
IoBuffer
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by three.
getUnsignedMediumInt
在类中 IoBuffer
public int getMediumInt(int index)
IoBuffer
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
getMediumInt
在类中 IoBuffer
index
- The index from which the medium int will be readpublic int getUnsignedMediumInt(int index)
IoBuffer
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
getUnsignedMediumInt
在类中 IoBuffer
index
- The index from which the unsigned medium int will be readpublic IoBuffer putMediumInt(int value)
IoBuffer
Writes three bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by three.
putMediumInt
在类中 IoBuffer
value
- The medium int value to be writtenpublic IoBuffer putMediumInt(int index, int value)
IoBuffer
Writes three bytes containing the given int value, in the current byte order, into this buffer at the given index.
putMediumInt
在类中 IoBuffer
index
- The index at which the bytes will be writtenvalue
- The medium int value to be writtenpublic java.lang.String getHexDump(int lengthLimit)
IoBuffer
getHexDump
在类中 IoBuffer
lengthLimit
- The maximum number of bytes to dump from the current buffer
position.public boolean prefixedDataAvailable(int prefixLength)
prefixedDataAvailable
在类中 IoBuffer
prefixLength
- the length of the prefix field (1, 2, or 4)IoBuffer.prefixedDataAvailable(int, int)
instead.public boolean prefixedDataAvailable(int prefixLength, int maxDataLength)
prefixedDataAvailable
在类中 IoBuffer
prefixLength
- the length of the prefix field (1, 2, or 4)maxDataLength
- the allowed maximum of the read data lengthpublic int indexOf(byte b)
IoBuffer
public <E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> enumClass)
IoBuffer
public <E extends java.lang.Enum<E>> E getEnum(int index, java.lang.Class<E> enumClass)
IoBuffer
public <E extends java.lang.Enum<E>> E getEnumShort(java.lang.Class<E> enumClass)
IoBuffer
getEnumShort
在类中 IoBuffer
E
- The enum type to returnenumClass
- The enum's class objectpublic <E extends java.lang.Enum<E>> E getEnumShort(int index, java.lang.Class<E> enumClass)
IoBuffer
getEnumShort
在类中 IoBuffer
E
- The enum type to returnindex
- the index from which the bytes will be readenumClass
- The enum's class objectpublic <E extends java.lang.Enum<E>> E getEnumInt(java.lang.Class<E> enumClass)
IoBuffer
getEnumInt
在类中 IoBuffer
E
- The enum type to returnenumClass
- The enum's class objectpublic <E extends java.lang.Enum<E>> E getEnumInt(int index, java.lang.Class<E> enumClass)
IoBuffer
getEnumInt
在类中 IoBuffer
E
- The enum type to returnindex
- the index from which the bytes will be readenumClass
- The enum's class objectpublic IoBuffer putEnum(java.lang.Enum<?> e)
IoBuffer
public IoBuffer putEnum(int index, java.lang.Enum<?> e)
IoBuffer
public IoBuffer putEnumShort(java.lang.Enum<?> e)
IoBuffer
putEnumShort
在类中 IoBuffer
e
- The enum to write to the bufferpublic IoBuffer putEnumShort(int index, java.lang.Enum<?> e)
IoBuffer
putEnumShort
在类中 IoBuffer
index
- The index at which the bytes will be writtene
- The enum to write to the bufferpublic IoBuffer putEnumInt(java.lang.Enum<?> e)
IoBuffer
putEnumInt
在类中 IoBuffer
e
- The enum to write to the bufferpublic IoBuffer putEnumInt(int index, java.lang.Enum<?> e)
IoBuffer
putEnumInt
在类中 IoBuffer
index
- The index at which the bytes will be writtene
- The enum to write to the bufferpublic <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSet(java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.
Each bit is mapped to a value in the specified enum. The least significant bit maps to the first entry in the specified enum and each subsequent bit maps to each subsequent bit as mapped to the subsequent enum value.
getEnumSet
在类中 IoBuffer
E
- the enum typeenumClass
- the enum class used to create the EnumSetpublic <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSet(int index, java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSet
在类中 IoBuffer
E
- the enum typeindex
- the index from which the byte will be readenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetShort(java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetShort
在类中 IoBuffer
E
- the enum typeenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetShort(int index, java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetShort
在类中 IoBuffer
E
- the enum typeindex
- the index from which the bytes will be readenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetInt(java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetInt
在类中 IoBuffer
E
- the enum typeenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetInt(int index, java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetInt
在类中 IoBuffer
E
- the enum typeindex
- the index from which the bytes will be readenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetLong(java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetLong
在类中 IoBuffer
E
- the enum typeenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> java.util.EnumSet<E> getEnumSetLong(int index, java.lang.Class<E> enumClass)
IoBuffer
EnumSet
.getEnumSetLong
在类中 IoBuffer
E
- the enum typeindex
- the index from which the bytes will be readenumClass
- the enum class used to create the EnumSetIoBuffer.getEnumSet(Class)
public <E extends java.lang.Enum<E>> IoBuffer putEnumSet(java.util.Set<E> set)
IoBuffer
Set
to the buffer as a byte sized bit
vector.putEnumSet
在类中 IoBuffer
E
- the enum type of the Setset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSet(int index, java.util.Set<E> set)
IoBuffer
Set
to the buffer as a byte sized bit
vector.putEnumSet
在类中 IoBuffer
E
- the enum type of the Setindex
- the index at which the byte will be writtenset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetShort(java.util.Set<E> set)
IoBuffer
Set
to the buffer as a short sized bit
vector.putEnumSetShort
在类中 IoBuffer
E
- the enum type of the Setset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetShort(int index, java.util.Set<E> set)
IoBuffer
Set
to the buffer as a short sized bit
vector.putEnumSetShort
在类中 IoBuffer
E
- the enum type of the Setindex
- the index at which the bytes will be writtenset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetInt(java.util.Set<E> set)
IoBuffer
Set
to the buffer as an int sized bit
vector.putEnumSetInt
在类中 IoBuffer
E
- the enum type of the Setset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetInt(int index, java.util.Set<E> set)
IoBuffer
Set
to the buffer as an int sized bit
vector.putEnumSetInt
在类中 IoBuffer
E
- the enum type of the Setindex
- the index at which the bytes will be writtenset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetLong(java.util.Set<E> set)
IoBuffer
Set
to the buffer as a long sized bit
vector.putEnumSetLong
在类中 IoBuffer
E
- the enum type of the Setset
- the enum set to write to the bufferpublic <E extends java.lang.Enum<E>> IoBuffer putEnumSetLong(int index, java.util.Set<E> set)
IoBuffer
Set
to the buffer as a long sized bit
vector.putEnumSetLong
在类中 IoBuffer
E
- the enum type of the Setindex
- the index at which the bytes will be writtenset
- the enum set to write to the bufferpublic IoBuffer putUnsigned(byte value)
IoBuffer
putUnsigned
在类中 IoBuffer
value
- the byte to writepublic IoBuffer putUnsigned(int index, byte value)
IoBuffer
putUnsigned
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the byte to writepublic IoBuffer putUnsigned(short value)
IoBuffer
putUnsigned
在类中 IoBuffer
value
- the short to writepublic IoBuffer putUnsigned(int index, short value)
IoBuffer
putUnsigned
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the short to writepublic IoBuffer putUnsigned(int value)
IoBuffer
putUnsigned
在类中 IoBuffer
value
- the int to writepublic IoBuffer putUnsigned(int index, int value)
IoBuffer
putUnsigned
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the int to writepublic IoBuffer putUnsigned(long value)
IoBuffer
putUnsigned
在类中 IoBuffer
value
- the long to writepublic IoBuffer putUnsigned(int index, long value)
IoBuffer
putUnsigned
在类中 IoBuffer
index
- the position in the buffer to write the valuevalue
- the long to write