public abstract class AbstractIoBuffer extends IoBuffer
IoBuffer
. This implementation
assumes that IoBuffer.buf()
always returns a correct NIO
ByteBuffer
instance. Most implementations could
extend this class and implement their own buffer management mechanism.IoBufferAllocator
Modifier | Constructor and Description |
---|---|
protected |
AbstractIoBuffer(AbstractIoBuffer parent)
Creates a new derived buffer.
|
protected |
AbstractIoBuffer(IoBufferAllocator allocator,
int initialCapacity)
Creates a new parent buffer.
|
Modifier and Type | Method and Description |
---|---|
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. |
IoBuffer |
asReadOnlyBuffer() |
protected abstract IoBuffer |
asReadOnlyBuffer0()
Implement this method to return the unexpandable read only version of
this buffer.
|
java.nio.ShortBuffer |
asShortBuffer() |
protected abstract void |
buf(java.nio.ByteBuffer newBuf)
Sets the underlying NIO buffer instance.
|
int |
capacity() |
IoBuffer |
capacity(int newCapacity)
Increases the capacity of this buffer.
|
IoBuffer |
clear() |
IoBuffer |
compact() |
int |
compareTo(IoBuffer that) |
IoBuffer |
duplicate() |
protected abstract IoBuffer |
duplicate0()
Implement this method to return the unexpandable duplicate of this
buffer.
|
boolean |
equals(java.lang.Object o) |
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() |
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.
|
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)
TODO document me.
|
IoBuffer |
getSlice(int index,
int length)
TODO document me.
|
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.
|
int |
hashCode() |
boolean |
hasRemaining() |
int |
indexOf(byte b)
Returns the first occurence position of the specified byte from the
current position to the current limit.
|
boolean |
isAutoExpand()
Returns true if and only if autoExpand is turned on.
|
boolean |
isAutoShrink()
Returns true if and only if autoShrink is turned on.
|
boolean |
isDerived()
returns true if and only if this buffer is derived from other
buffer via
IoBuffer.duplicate() , IoBuffer.slice() or
IoBuffer.asReadOnlyBuffer() . |
boolean |
isDirect() |
boolean |
isReadOnly() |
int |
limit() |
IoBuffer |
limit(int newLimit) |
IoBuffer |
mark() |
int |
markValue()
Returns the position of the current mark.
|
int |
minimumCapacity()
Returns 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. |
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)
Returns true if this buffer contains a data which has a data
length as a prefix and the buffer has remaining data as enough as
specified in the data length field.
|
boolean |
prefixedDataAvailable(int prefixLength,
int maxDataLength)
Returns true if this buffer contains a data which has a data
length as a prefix and the buffer has remaining data as enough as
specified in the data length field.
|
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 val,
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 . |
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 val,
java.nio.charset.CharsetEncoder encoder)
Writes the content of
in into this buffer using the
specified encoder . |
IoBuffer |
putString(java.lang.CharSequence val,
int fieldSize,
java.nio.charset.CharsetEncoder encoder)
Writes the content of
in into this buffer as a
NUL -terminated string using the specified
encoder . |
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() |
protected abstract IoBuffer |
slice0()
Implement this method to return the unexpandable slice of this
buffer.
|
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, array, arrayOffset, buf, free, getAllocator, hasArray, isUseDirectBuffer, normalizeCapacity, setAllocator, setUseDirectBuffer, wrap, wrap, wrap
protected AbstractIoBuffer(IoBufferAllocator allocator, int initialCapacity)
allocator
- The allocator to use to create new buffersinitialCapacity
- The initial buffer capacity when createdprotected AbstractIoBuffer(AbstractIoBuffer parent)
parent
- The buffer we get the properties frompublic final boolean isDirect()
public final boolean isReadOnly()
isReadOnly
in class IoBuffer
Buffer.isReadOnly()
protected abstract void buf(java.nio.ByteBuffer newBuf)
newBuf
- The buffer to store within this IoBufferpublic final int minimumCapacity()
IoBuffer.compact()
and
IoBuffer.shrink()
operation. The default value is the initial capacity of
the buffer.minimumCapacity
in class IoBuffer
public final IoBuffer minimumCapacity(int minimumCapacity)
IoBuffer.compact()
and
IoBuffer.shrink()
operation. The default value is the initial capacity of
the buffer.minimumCapacity
in class IoBuffer
public final int capacity()
public final IoBuffer capacity(int newCapacity)
public final boolean isAutoExpand()
isAutoExpand
in class IoBuffer
public final boolean isAutoShrink()
isAutoShrink
in class IoBuffer
public final boolean isDerived()
IoBuffer.duplicate()
, IoBuffer.slice()
or
IoBuffer.asReadOnlyBuffer()
.public final IoBuffer setAutoExpand(boolean autoExpand)
setAutoExpand
in class IoBuffer
public final IoBuffer setAutoShrink(boolean autoShrink)
setAutoShrink
in class IoBuffer
public final IoBuffer expand(int expectedRemaining)
public final IoBuffer expand(int pos, int expectedRemaining)
public final IoBuffer shrink()
IoBuffer.minimumCapacity()
. The mark is discarded once
the capacity changes.public final int position()
public final IoBuffer position(int newPosition)
public final IoBuffer limit(int newLimit)
public final int markValue()
public final IoBuffer sweep()
public final IoBuffer sweep(byte value)
public final IoBuffer rewind()
public final int remaining()
public final boolean hasRemaining()
hasRemaining
in class IoBuffer
Buffer.hasRemaining()
public final short getUnsigned()
getUnsigned
in class IoBuffer
public final IoBuffer put(byte b)
public final byte get(int index)
public final short getUnsigned(int index)
getUnsigned
in class IoBuffer
public final IoBuffer put(int index, byte b)
public final IoBuffer get(byte[] dst, int offset, int length)
public final IoBuffer put(java.nio.ByteBuffer src)
public final IoBuffer put(byte[] src, int offset, int length)
public final IoBuffer compact()
public final java.nio.ByteOrder order()
public final IoBuffer order(java.nio.ByteOrder bo)
public final char getChar()
public final IoBuffer putChar(char value)
public final char getChar(int index)
public final IoBuffer putChar(int index, char value)
public final java.nio.CharBuffer asCharBuffer()
asCharBuffer
in class IoBuffer
ByteBuffer.asCharBuffer()
public final short getShort()
public final IoBuffer putShort(short value)
public final short getShort(int index)
public final IoBuffer putShort(int index, short value)
public final java.nio.ShortBuffer asShortBuffer()
asShortBuffer
in class IoBuffer
ByteBuffer.asShortBuffer()
public final int getInt()
public final IoBuffer putInt(int value)
public final int getInt(int index)
public final IoBuffer putInt(int index, int value)
public final java.nio.IntBuffer asIntBuffer()
asIntBuffer
in class IoBuffer
ByteBuffer.asIntBuffer()
public final long getLong()
public final IoBuffer putLong(long value)
public final long getLong(int index)
public final IoBuffer putLong(int index, long value)
public final java.nio.LongBuffer asLongBuffer()
asLongBuffer
in class IoBuffer
ByteBuffer.asLongBuffer()
public final float getFloat()
public final IoBuffer putFloat(float value)
public final float getFloat(int index)
public final IoBuffer putFloat(int index, float value)
public final java.nio.FloatBuffer asFloatBuffer()
asFloatBuffer
in class IoBuffer
ByteBuffer.asFloatBuffer()
public final double getDouble()
public final IoBuffer putDouble(double value)
public final double getDouble(int index)
public final IoBuffer putDouble(int index, double value)
public final java.nio.DoubleBuffer asDoubleBuffer()
asDoubleBuffer
in class IoBuffer
ByteBuffer.asDoubleBuffer()
public final IoBuffer asReadOnlyBuffer()
asReadOnlyBuffer
in class IoBuffer
ByteBuffer.asReadOnlyBuffer()
protected abstract IoBuffer asReadOnlyBuffer0()
public final IoBuffer duplicate()
protected abstract IoBuffer duplicate0()
public final IoBuffer slice()
public final IoBuffer getSlice(int index, int length)
public final IoBuffer getSlice(int length)
protected abstract IoBuffer slice0()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(IoBuffer that)
public java.lang.String toString()
toString
in class java.lang.Object
public IoBuffer get(byte[] dst)
public IoBuffer put(byte[] src)
public int getUnsignedShort()
getUnsignedShort
in class IoBuffer
public int getUnsignedShort(int index)
getUnsignedShort
in class IoBuffer
public long getUnsignedInt()
getUnsignedInt
in class IoBuffer
public int getMediumInt()
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
in class IoBuffer
public int getUnsignedMediumInt()
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
in class IoBuffer
public int getMediumInt(int index)
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
getMediumInt
in class IoBuffer
index
- The index from which the medium int will be readpublic int getUnsignedMediumInt(int index)
Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
getUnsignedMediumInt
in class IoBuffer
index
- The index from which the unsigned medium int will be readpublic IoBuffer putMediumInt(int value)
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
in class IoBuffer
value
- The medium int value to be writtenpublic IoBuffer putMediumInt(int index, int value)
Writes three bytes containing the given int value, in the current byte order, into this buffer at the given index.
putMediumInt
in class IoBuffer
index
- The index at which the bytes will be writtenvalue
- The medium int value to be writtenpublic long getUnsignedInt(int index)
getUnsignedInt
in class IoBuffer
public java.io.InputStream asInputStream()
InputStream
that reads the data from this buffer.
InputStream.read()
returns -1 if the buffer position
reaches to the limit.asInputStream
in class IoBuffer
public java.io.OutputStream asOutputStream()
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.asOutputStream
in class IoBuffer
public java.lang.String getHexDump()
getHexDump
in class IoBuffer
public java.lang.String getHexDump(int lengthLimit)
getHexDump
in class IoBuffer
lengthLimit
- The maximum number of bytes to dump from the current buffer
position.public java.lang.String getString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
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 getString(int fieldSize, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
NUL
-terminated string from this buffer using the
specified decoder
and returns it.public IoBuffer putString(java.lang.CharSequence val, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
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 putString(java.lang.CharSequence val, int fieldSize, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
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 java.lang.String getPrefixedString(java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
decoder
and returns it. This
method is a shortcut for getPrefixedString(2, decoder).getPrefixedString
in class IoBuffer
java.nio.charset.CharacterCodingException
public java.lang.String getPrefixedString(int prefixLength, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
decoder
and returns it.getPrefixedString
in class IoBuffer
prefixLength
- the length of the length field (1, 2, or 4)decoder
- the decoder to use for decoding the stringjava.nio.charset.CharacterCodingException
- when decoding failsjava.nio.BufferUnderflowException
- when there is not enough data availablepublic IoBuffer putPrefixedString(java.lang.CharSequence in, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
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
in class IoBuffer
java.nio.charset.CharacterCodingException
public IoBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
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
in class IoBuffer
prefixLength
- the length of the length field (1, 2, or 4)java.nio.charset.CharacterCodingException
public IoBuffer putPrefixedString(java.lang.CharSequence in, int prefixLength, int padding, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
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
in class IoBuffer
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 IoBuffer putPrefixedString(java.lang.CharSequence val, int prefixLength, int padding, byte padValue, java.nio.charset.CharsetEncoder encoder) throws java.nio.charset.CharacterCodingException
in
into this buffer as a string which
has a 16-bit length field before the actual encoded string, using the
specified encoder
.putPrefixedString
in class IoBuffer
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 java.lang.Object getObject() throws java.lang.ClassNotFoundException
ClassLoader
of the current thread.public java.lang.Object getObject(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
public IoBuffer putObject(java.lang.Object o)
public boolean prefixedDataAvailable(int prefixLength)
IoBuffer.prefixedDataAvailable(int, int)
instead.prefixedDataAvailable
in class IoBuffer
prefixLength
- the length of the prefix field (1, 2, or 4)public boolean prefixedDataAvailable(int prefixLength, int maxDataLength)
prefixedDataAvailable
in class 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)
public IoBuffer skip(int size)
size
bytes.public IoBuffer fill(byte value, int size)
public IoBuffer fillAndReset(byte value, int size)
fillAndReset
in class IoBuffer
public IoBuffer fill(int size)
NUL (0x00)
. This method moves buffer
position forward.public IoBuffer fillAndReset(int size)
NUL (0x00)
. This method does not
change buffer position.fillAndReset
in class IoBuffer
public <E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> enumClass)
public <E extends java.lang.Enum<E>> E getEnum(int index, java.lang.Class<E> enumClass)
public <E extends java.lang.Enum<E>> E getEnumShort(java.lang.Class<E> enumClass)
getEnumShort
in class 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)
getEnumShort
in class 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)
getEnumInt
in class 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)
getEnumInt
in class 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)
public IoBuffer putEnum(int index, java.lang.Enum<?> e)
public IoBuffer putEnumShort(java.lang.Enum<?> e)
putEnumShort
in class IoBuffer
e
- The enum to write to the bufferpublic IoBuffer putEnumShort(int index, java.lang.Enum<?> e)
putEnumShort
in class IoBuffer
index
- The index at which the bytes will be writtene
- The enum to write to the bufferpublic IoBuffer putEnumInt(java.lang.Enum<?> e)
putEnumInt
in class IoBuffer
e
- The enum to write to the bufferpublic IoBuffer putEnumInt(int index, java.lang.Enum<?> e)
putEnumInt
in class 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)
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
in class 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)
EnumSet
.getEnumSet
in class 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)
EnumSet
.getEnumSetShort
in class 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)
EnumSet
.getEnumSetShort
in class 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)
EnumSet
.getEnumSetInt
in class 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)
EnumSet
.getEnumSetInt
in class 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)
EnumSet
.getEnumSetLong
in class 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)
EnumSet
.getEnumSetLong
in class 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)
Set
to the buffer as a byte sized bit
vector.putEnumSet
in class 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)
Set
to the buffer as a byte sized bit
vector.putEnumSet
in class 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)
Set
to the buffer as a short sized bit
vector.putEnumSetShort
in class 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)
Set
to the buffer as a short sized bit
vector.putEnumSetShort
in class 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)
Set
to the buffer as an int sized bit
vector.putEnumSetInt
in class 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)
Set
to the buffer as an int sized bit
vector.putEnumSetInt
in class 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)
Set
to the buffer as a long sized bit
vector.putEnumSetLong
in class 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)
Set
to the buffer as a long sized bit
vector.putEnumSetLong
in class IoBuffer
E
- the enum type of the Setindex
- the index at which the bytes will be writtenset
- the enum set to write to the bufferCopyright © 2004-2019 Apache MINA Project. All Rights Reserved.