| java.lang.Object org.apache.mina.common.IoBuffer
All known Subclasses: org.apache.mina.common.AbstractIoBuffer, org.apache.mina.common.IoBufferWrapper,
IoBuffer | abstract public class IoBuffer implements Comparable<IoBuffer>(Code) | | A byte buffer used by MINA applications.
This is a replacement for
ByteBuffer . Please refer to
ByteBuffer documentation for preliminary usage. MINA does
not use NIO
ByteBuffer directly for two reasons:
- It doesn't provide useful getters and putters such as
fill , get/putString , and
get/putAsciiInt() enough.
- It is difficult to write variable-length data due to its fixed
capacity
Allocation
You can allocate a new heap buffer.
IoBuffer buf = IoBuffer.allocate(1024, false);
you can also allocate a new direct buffer:
IoBuffer buf = IoBuffer.allocate(1024, true);
or you can set the default buffer type.
// Allocate heap buffer by default.
IoBuffer.setUseDirectBuffer(false);
// A new heap buffer is returned.
IoBuffer buf = IoBuffer.allocate(1024);
Wrapping existing NIO buffers and arrays
This class provides a few wrap(...) methods that wraps
any NIO buffers and byte arrays.
AutoExpand
Writing variable-length data using NIO ByteBuffers is not really
easy, and it is because its size is fixed.
IoBuffer introduces
autoExpand property. If autoExpand property is true, you
never get
BufferOverflowException or
IndexOutOfBoundsException (except when index is negative).
It automatically expands its capacity and limit value. For example:
String greeting = messageBundle.getMessage( "hello" );
IoBuffer buf = IoBuffer.allocate( 16 );
// Turn on autoExpand (it is off by default)
buf.setAutoExpand( true );
buf.putString( greeting, utf8encoder );
The underlying
ByteBuffer is reallocated by
IoBuffer behind
the scene if the encoded data is larger than 16 bytes in the example above.
Its capacity will double, and its limit will increase to the last position
the string is written.
AutoShrink
You might also want to decrease the capacity of the buffer when most
of the allocated memory area is not being used.
IoBuffer provides
autoShrink property to take care of this issue. If
autoShrink is turned on,
IoBuffer halves the capacity
of the buffer when
IoBuffer.compact() is invoked and only 1/4 or less of
the current capacity is being used.
You can also
IoBuffer.shrink() method manually to shrink the capacity of
the buffer.
The underlying
ByteBuffer is reallocated by
IoBuffer behind
the scene, and therefore
IoBuffer.buf() will return a different
ByteBuffer instance once capacity changes. Please also note
IoBuffer.compact() or
IoBuffer.shrink() will not decrease the capacity if
the new capacity is less than the
IoBuffer.minimumCapacity() of the buffer.
Derived Buffers
Derived buffers are the buffers which were created by
IoBuffer.duplicate() ,
IoBuffer.slice() , or
IoBuffer.asReadOnlyBuffer() .
They are useful especially when you broadcast the same messages to
multiple
IoSession s. Please note that the buffer derived from and
its derived buffers are not both auto-expandable neither auto-shrinkable.
Trying to call
IoBuffer.setAutoExpand(boolean) or
IoBuffer.setAutoShrink(boolean) with true parameter will raise an
IllegalStateException .
Changing Buffer Allocation Policy
IoBufferAllocator interface lets you override the default buffer
management behavior. There are two allocators provided out-of-the-box:
You can implement your own allocator and use it by calling
IoBuffer.setAllocator(IoBufferAllocator) .
author: The Apache MINA Project (dev@mina.apache.org) version: $Rev: 602109 $, $Date: 2007-12-07 07:40:41 -0700 (Fri, 07 Dec 2007) $ |
Constructor Summary | |
protected | IoBuffer() Creates a new instance. |
Method Summary | |
public static IoBuffer | allocate(int capacity) Returns the direct or heap buffer which is capable to store the
specified amount of bytes. | public static IoBuffer | allocate(int capacity, boolean direct) Returns the buffer which is capable of the specified size. | abstract public byte[] | array() | abstract public int | arrayOffset() | abstract public CharBuffer | asCharBuffer() | abstract public DoubleBuffer | asDoubleBuffer() | abstract public FloatBuffer | asFloatBuffer() | abstract public InputStream | asInputStream() Returns an
InputStream that reads the data from this buffer. | abstract public IntBuffer | asIntBuffer() | abstract public LongBuffer | asLongBuffer() | abstract public OutputStream | asOutputStream() Returns an
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. | abstract public IoBuffer | asReadOnlyBuffer() | abstract public ShortBuffer | asShortBuffer() | abstract public ByteBuffer | buf() Returns the underlying NIO buffer instance. | abstract public int | capacity() | abstract public IoBuffer | capacity(int newCapacity) Increases the capacity of this buffer. | abstract public IoBuffer | clear() | abstract public IoBuffer | compact() | abstract public IoBuffer | duplicate() | abstract public IoBuffer | expand(int expectedRemaining) Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the current position. | abstract public IoBuffer | expand(int position, int expectedRemaining) Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the specified
position. | abstract public IoBuffer | fill(byte value, int size) Fills this buffer with the specified value. | abstract public IoBuffer | fill(int size) Fills this buffer with NUL (0x00) . | abstract public IoBuffer | fillAndReset(byte value, int size) Fills this buffer with the specified value. | abstract public IoBuffer | fillAndReset(int size) Fills this buffer with NUL (0x00) . | abstract public IoBuffer | flip() | abstract public void | free() Declares this buffer and all its derived buffers are not used anymore
so that it can be reused by some
IoBufferAllocator implementations.
It is not mandatory to call this method, but you might want to invoke this
method for maximum performance. | abstract public byte | get() | abstract public byte | get(int index) | abstract public IoBuffer | get(byte[] dst, int offset, int length) | abstract public IoBuffer | get(byte[] dst) | public static IoBufferAllocator | getAllocator() | abstract public char | getChar() | abstract public char | getChar(int index) | abstract public double | getDouble() | abstract public double | getDouble(int index) | abstract public E | getEnum(Class<E> enumClass) Reads a byte from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public E | getEnum(int index, Class<E> enumClass) Reads a byte from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public E | getEnumInt(Class<E> enumClass) Reads an int from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public E | getEnumInt(int index, Class<E> enumClass) Reads an int from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public EnumSet<E> | getEnumSet(Class<E> enumClass) Reads a byte sized bit vector and converts it to an
EnumSet .
Each bit is mapped to a value in the specified enum. | abstract public EnumSet<E> | getEnumSet(int index, Class<E> enumClass) Reads a byte sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetInt(Class<E> enumClass) Reads an int sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetInt(int index, Class<E> enumClass) Reads an int sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetLong(Class<E> enumClass) Reads a long sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetLong(int index, Class<E> enumClass) Reads a long sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetShort(Class<E> enumClass) Reads a short sized bit vector and converts it to an
EnumSet . | abstract public EnumSet<E> | getEnumSetShort(int index, Class<E> enumClass) Reads a short sized bit vector and converts it to an
EnumSet . | abstract public E | getEnumShort(Class<E> enumClass) Reads a short from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public E | getEnumShort(int index, Class<E> enumClass) Reads a short from the buffer and returns the correlating enum constant defined
by the specified enum type. | abstract public float | getFloat() | abstract public float | getFloat(int index) | abstract public String | getHexDump() Returns hexdump of this buffer. | abstract public String | getHexDump(int lengthLimit) Return hexdump of this buffer with limited length. | abstract public int | getInt() | abstract public int | getInt(int index) | abstract public long | getLong() | abstract public long | getLong(int index) | abstract public int | getMediumInt() Relative get method for reading a medium int value. | abstract public int | getMediumInt(int index) Absolute get method for reading a medium int value. | abstract public Object | getObject() Reads a Java object from the buffer using the context
ClassLoader of the current thread. | abstract public Object | getObject(ClassLoader classLoader) Reads a Java object from the buffer using the specified classLoader. | abstract public String | getPrefixedString(CharsetDecoder decoder) Reads a string which has a 16-bit length field before the actual
encoded string, using the specified decoder and returns it. | abstract public String | getPrefixedString(int prefixLength, CharsetDecoder decoder) Reads a string which has a length field before the actual
encoded string, using the specified decoder and returns it. | abstract public short | getShort() | abstract public short | getShort(int index) | abstract public IoBuffer | getSlice(int index, int length) TODO document me. | abstract public IoBuffer | getSlice(int length) TODO document me. | abstract public String | getString(CharsetDecoder decoder) Reads a NUL -terminated string from this buffer using the
specified decoder and returns it. | abstract public String | getString(int fieldSize, CharsetDecoder decoder) Reads a NUL -terminated string from this buffer using the
specified decoder and returns it. | abstract public short | getUnsigned() Reads one unsigned byte as a short integer. | abstract public short | getUnsigned(int index) Reads one byte as an unsigned short integer. | abstract public long | getUnsignedInt() Reads four bytes unsigned integer. | abstract public long | getUnsignedInt(int index) Reads four bytes unsigned integer. | abstract public int | getUnsignedMediumInt() Relative get method for reading an unsigned medium int value. | abstract public int | getUnsignedMediumInt(int index) Absolute get method for reading an unsigned medium int value. | abstract public int | getUnsignedShort() Reads two bytes unsigned integer. | abstract public int | getUnsignedShort(int index) Reads two bytes unsigned integer. | abstract public boolean | hasArray() | abstract public boolean | hasRemaining() | abstract public int | indexOf(byte b) Returns the first occurence position of the specified byte from the current position to
the current limit. | abstract public boolean | isAutoExpand() Returns true if and only if autoExpand is turned on. | abstract public boolean | isAutoShrink() Returns true if and only if autoShrink is turned on. | abstract public boolean | isDerived() returns true if and only if this buffer is derived from other buffer
via
IoBuffer.duplicate() ,
IoBuffer.slice() or
IoBuffer.asReadOnlyBuffer() . | abstract public boolean | isDirect() | abstract public boolean | isReadOnly() | public static boolean | isUseDirectBuffer() Returns true if and only if a direct buffer is allocated
by default when the type of the new buffer is not specified. | abstract public int | limit() | abstract public IoBuffer | limit(int newLimit) | abstract public IoBuffer | mark() | abstract public int | markValue() Returns the position of the current mark. | abstract public 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. | abstract public 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. | protected static int | normalizeCapacity(int requestedCapacity) Normalizes the specified capacity of the buffer to power of 2,
which is often helpful for optimal memory usage and performance. | abstract public ByteOrder | order() | abstract public IoBuffer | order(ByteOrder bo) | abstract public int | position() | abstract public IoBuffer | position(int newPosition) | abstract public 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. | abstract public 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. | abstract public IoBuffer | put(byte b) | abstract public IoBuffer | put(int index, byte b) | abstract public IoBuffer | put(ByteBuffer src) Writes the content of the specified src into this buffer. | abstract public IoBuffer | put(IoBuffer src) Writes the content of the specified src into this buffer. | abstract public IoBuffer | put(byte[] src, int offset, int length) | abstract public IoBuffer | put(byte[] src) | abstract public IoBuffer | putChar(char value) | abstract public IoBuffer | putChar(int index, char value) | abstract public IoBuffer | putDouble(double value) | abstract public IoBuffer | putDouble(int index, double value) | abstract public IoBuffer | putEnum(Enum> e) Writes an enum's ordinal value to the buffer as a byte. | abstract public IoBuffer | putEnum(int index, Enum> e) Writes an enum's ordinal value to the buffer as a byte. | abstract public IoBuffer | putEnumInt(Enum> e) Writes an enum's ordinal value to the buffer as an integer. | abstract public IoBuffer | putEnumInt(int index, Enum> e) Writes an enum's ordinal value to the buffer as an integer. | abstract public IoBuffer | putEnumSet(Set<E> set) Writes the specified
Set to the buffer as a byte sized bit vector. | abstract public IoBuffer | putEnumSet(int index, Set<E> set) Writes the specified
Set to the buffer as a byte sized bit vector. | abstract public IoBuffer | putEnumSetInt(Set<E> set) Writes the specified
Set to the buffer as an int sized bit vector. | abstract public IoBuffer | putEnumSetInt(int index, Set<E> set) Writes the specified
Set to the buffer as an int sized bit vector. | abstract public IoBuffer | putEnumSetLong(Set<E> set) Writes the specified
Set to the buffer as a long sized bit vector. | abstract public IoBuffer | putEnumSetLong(int index, Set<E> set) Writes the specified
Set to the buffer as a long sized bit vector. | abstract public IoBuffer | putEnumSetShort(Set<E> set) Writes the specified
Set to the buffer as a short sized bit vector. | abstract public IoBuffer | putEnumSetShort(int index, Set<E> set) Writes the specified
Set to the buffer as a short sized bit vector. | abstract public IoBuffer | putEnumShort(Enum> e) Writes an enum's ordinal value to the buffer as a short. | abstract public IoBuffer | putEnumShort(int index, Enum> e) Writes an enum's ordinal value to the buffer as a short. | abstract public IoBuffer | putFloat(float value) | abstract public IoBuffer | putFloat(int index, float value) | abstract public IoBuffer | putInt(int value) | abstract public IoBuffer | putInt(int index, int value) | abstract public IoBuffer | putLong(long value) | abstract public IoBuffer | putLong(int index, long value) | abstract public IoBuffer | putMediumInt(int value) Relative put method for writing a medium int
value. | abstract public IoBuffer | putMediumInt(int index, int value) Absolute put method for writing a medium int
value. | abstract public IoBuffer | putObject(Object o) Writes the specified Java object to the buffer. | abstract public IoBuffer | putPrefixedString(CharSequence in, 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 . | abstract public IoBuffer | putPrefixedString(CharSequence in, int prefixLength, 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 . | abstract public IoBuffer | putPrefixedString(CharSequence in, int prefixLength, int padding, 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 . | abstract public IoBuffer | putPrefixedString(CharSequence val, int prefixLength, int padding, byte padValue, 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 . | abstract public IoBuffer | putShort(short value) | abstract public IoBuffer | putShort(int index, short value) | abstract public IoBuffer | putString(CharSequence val, CharsetEncoder encoder) Writes the content of in into this buffer using the
specified encoder . | abstract public IoBuffer | putString(CharSequence val, int fieldSize, CharsetEncoder encoder) Writes the content of in into this buffer as a
NUL -terminated string using the specified
encoder . | abstract public int | remaining() | abstract public IoBuffer | reset() | abstract public IoBuffer | rewind() | public static void | setAllocator(IoBufferAllocator newAllocator) | abstract public IoBuffer | setAutoExpand(boolean autoExpand) Turns on or off autoExpand. | abstract public IoBuffer | setAutoShrink(boolean autoShrink) Turns on or off autoShrink. | public static void | setUseDirectBuffer(boolean useDirectBuffer) Sets if a direct buffer should be allocated by default when the
type of the new buffer is not specified. | abstract public 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. | abstract public IoBuffer | skip(int size) Forwards the position of this buffer as the specified size
bytes. | abstract public IoBuffer | slice() | abstract public IoBuffer | sweep() Clears this buffer and fills its content with NUL. | abstract public IoBuffer | sweep(byte value) Clears this buffer and fills its content with value. | public static IoBuffer | wrap(ByteBuffer nioBuffer) Wraps the specified NIO
ByteBuffer into MINA buffer. | public static IoBuffer | wrap(byte[] byteArray) Wraps the specified byte array into MINA heap buffer. | public static IoBuffer | wrap(byte[] byteArray, int offset, int length) Wraps the specified byte array into MINA heap buffer. |
EMPTY_BUFFER | final public static IoBuffer EMPTY_BUFFER(Code) | | An immutable empty buffer.
|
primitiveTypeNames | final protected static Set<String> primitiveTypeNames(Code) | | |
IoBuffer | protected IoBuffer()(Code) | | Creates a new instance. This is an empty constructor.
|
allocate | public static IoBuffer allocate(int capacity, boolean direct)(Code) | | Returns the buffer which is capable of the specified size.
Parameters: capacity - the capacity of the buffer Parameters: direct - true to get a direct buffer,false to get a heap buffer. |
array | abstract public byte[] array()(Code) | | See Also: ByteBuffer.array |
arrayOffset | abstract public int arrayOffset()(Code) | | See Also: ByteBuffer.arrayOffset |
asCharBuffer | abstract public CharBuffer asCharBuffer()(Code) | | See Also: ByteBuffer.asCharBuffer |
asDoubleBuffer | abstract public DoubleBuffer asDoubleBuffer()(Code) | | See Also: ByteBuffer.asDoubleBuffer |
asFloatBuffer | abstract public FloatBuffer asFloatBuffer()(Code) | | See Also: ByteBuffer.asFloatBuffer |
asIntBuffer | abstract public IntBuffer asIntBuffer()(Code) | | See Also: ByteBuffer.asIntBuffer |
asLongBuffer | abstract public LongBuffer asLongBuffer()(Code) | | See Also: ByteBuffer.asLongBuffer |
asReadOnlyBuffer | abstract public IoBuffer asReadOnlyBuffer()(Code) | | See Also: ByteBuffer.asReadOnlyBuffer |
asShortBuffer | abstract public ShortBuffer asShortBuffer()(Code) | | See Also: ByteBuffer.asShortBuffer |
buf | abstract public ByteBuffer buf()(Code) | | Returns the underlying NIO buffer instance.
|
capacity | abstract public int capacity()(Code) | | See Also: ByteBuffer.capacity |
capacity | abstract public IoBuffer capacity(int newCapacity)(Code) | | Increases the capacity of this buffer. If the new capacity is less than
or equal to the current capacity, this method returns silently. If the
new capacity is greater than the current capacity, the buffer is
reallocated while retaining the position, limit, mark and the content
of the buffer.
|
compact | abstract public IoBuffer compact()(Code) | | See Also: ByteBuffer.compact |
duplicate | abstract public IoBuffer duplicate()(Code) | | See Also: ByteBuffer.duplicate |
expand | abstract public IoBuffer expand(int expectedRemaining)(Code) | | Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the current position.
This method works even if you didn't set autoExpand to
true.
|
expand | abstract public IoBuffer expand(int position, int expectedRemaining)(Code) | | Changes the capacity and limit of this buffer so this buffer get
the specified expectedRemaining room from the specified
position.
This method works even if you didn't set autoExpand to
true.
|
fill | abstract public IoBuffer fill(byte value, int size)(Code) | | Fills this buffer with the specified value.
This method moves buffer position forward.
|
fill | abstract public IoBuffer fill(int size)(Code) | | Fills this buffer with NUL (0x00) .
This method moves buffer position forward.
|
fillAndReset | abstract public IoBuffer fillAndReset(byte value, int size)(Code) | | Fills this buffer with the specified value.
This method does not change buffer position.
|
fillAndReset | abstract public IoBuffer fillAndReset(int size)(Code) | | Fills this buffer with NUL (0x00) .
This method does not change buffer position.
|
free | abstract public void free()(Code) | | Declares this buffer and all its derived buffers are not used anymore
so that it can be reused by some
IoBufferAllocator implementations.
It is not mandatory to call this method, but you might want to invoke this
method for maximum performance.
|
get | abstract public byte get()(Code) | | See Also: ByteBuffer.get |
get | abstract public byte get(int index)(Code) | | See Also: ByteBuffer.get(int) |
get | abstract public IoBuffer get(byte[] dst, int offset, int length)(Code) | | See Also: ByteBuffer.get(byte[]intint) |
get | abstract public IoBuffer get(byte[] dst)(Code) | | See Also: ByteBuffer.get(byte[]) |
getAllocator | public static IoBufferAllocator getAllocator()(Code) | | Returns the allocator used by existing and new buffers
|
getChar | abstract public char getChar()(Code) | | See Also: ByteBuffer.getChar |
getChar | abstract public char getChar(int index)(Code) | | See Also: ByteBuffer.getChar(int) |
getDouble | abstract public double getDouble()(Code) | | See Also: ByteBuffer.getDouble |
getDouble | abstract public double getDouble(int index)(Code) | | See Also: ByteBuffer.getDouble(int) |
getEnum | abstract public E getEnum(Class<E> enumClass)(Code) | | Reads a byte from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: enumClass - The enum's class object |
getEnum | abstract public E getEnum(int index, Class<E> enumClass)(Code) | | Reads a byte from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: index - the index from which the byte will be read Parameters: enumClass - The enum's class object |
getEnumInt | abstract public E getEnumInt(Class<E> enumClass)(Code) | | Reads an int from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: enumClass - The enum's class object |
getEnumInt | abstract public E getEnumInt(int index, Class<E> enumClass)(Code) | | Reads an int from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: index - the index from which the bytes will be read Parameters: enumClass - The enum's class object |
getEnumSet | abstract public EnumSet<E> getEnumSet(Class<E> enumClass)(Code) | | Reads a byte sized bit vector and converts it to an
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.
< Parameters: E - > the enum type Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSet | abstract public EnumSet<E> getEnumSet(int index, Class<E> enumClass)(Code) | | Reads a byte sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: index - the index from which the byte will be read Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetInt | abstract public EnumSet<E> getEnumSetInt(Class<E> enumClass)(Code) | | Reads an int sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetInt | abstract public EnumSet<E> getEnumSetInt(int index, Class<E> enumClass)(Code) | | Reads an int sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: index - the index from which the bytes will be read Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetLong | abstract public EnumSet<E> getEnumSetLong(Class<E> enumClass)(Code) | | Reads a long sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetLong | abstract public EnumSet<E> getEnumSetLong(int index, Class<E> enumClass)(Code) | | Reads a long sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: index - the index from which the bytes will be read Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetShort | abstract public EnumSet<E> getEnumSetShort(Class<E> enumClass)(Code) | | Reads a short sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumSetShort | abstract public EnumSet<E> getEnumSetShort(int index, Class<E> enumClass)(Code) | | Reads a short sized bit vector and converts it to an
EnumSet .
See Also: IoBuffer.getEnumSet(Class)< Parameters: E - > the enum type Parameters: index - the index from which the bytes will be read Parameters: enumClass - the enum class used to create the EnumSet the EnumSet representation of the bit vector |
getEnumShort | abstract public E getEnumShort(Class<E> enumClass)(Code) | | Reads a short from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: enumClass - The enum's class object |
getEnumShort | abstract public E getEnumShort(int index, Class<E> enumClass)(Code) | | Reads a short from the buffer and returns the correlating enum constant defined
by the specified enum type.
< Parameters: E - > The enum type to return Parameters: index - the index from which the bytes will be read Parameters: enumClass - The enum's class object |
getFloat | abstract public float getFloat()(Code) | | See Also: ByteBuffer.getFloat |
getFloat | abstract public float getFloat(int index)(Code) | | See Also: ByteBuffer.getFloat(int) |
getHexDump | abstract public String getHexDump()(Code) | | Returns hexdump of this buffer. The data and pointer are
not changed as a result of this method call.
hexidecimal representation of this buffer |
getHexDump | abstract public String getHexDump(int lengthLimit)(Code) | | Return hexdump of this buffer with limited length.
Parameters: lengthLimit - The maximum number of bytes to dump fromthe current buffer position.hexidecimal representation of this buffer |
getInt | abstract public int getInt()(Code) | | See Also: ByteBuffer.getInt |
getInt | abstract public int getInt(int index)(Code) | | See Also: ByteBuffer.getInt(int) |
getLong | abstract public long getLong()(Code) | | See Also: ByteBuffer.getLong |
getLong | abstract public long getLong(int index)(Code) | | See Also: ByteBuffer.getLong(int) |
getMediumInt | abstract public int getMediumInt()(Code) | | Relative get method for reading a medium int value.
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.
The medium int value at the buffer's current position |
getMediumInt | abstract public int getMediumInt(int index)(Code) | | Absolute get method for reading a medium int value.
Reads the next three bytes at this buffer's current position,
composing them into an int value according to the current byte order.
Parameters: index - The index from which the medium int will be read The medium int value at the given index throws: IndexOutOfBoundsException - If index is negativeor not smaller than the buffer's limit |
getPrefixedString | abstract public String getPrefixedString(CharsetDecoder decoder) throws CharacterCodingException(Code) | | Reads a string which has a 16-bit length field before the actual
encoded string, using the specified decoder and returns it.
This method is a shortcut for getPrefixedString(2, decoder).
|
getPrefixedString | abstract public String getPrefixedString(int prefixLength, CharsetDecoder decoder) throws CharacterCodingException(Code) | | Reads a string which has a length field before the actual
encoded string, using the specified decoder and returns it.
Parameters: prefixLength - the length of the length field (1, 2, or 4) |
getShort | abstract public short getShort()(Code) | | See Also: ByteBuffer.getShort |
getShort | abstract public short getShort(int index)(Code) | | See Also: ByteBuffer.getShort |
getSlice | abstract public IoBuffer getSlice(int index, int length)(Code) | | TODO document me.
|
getSlice | abstract public IoBuffer getSlice(int length)(Code) | | TODO document me.
|
getString | abstract public String getString(CharsetDecoder decoder) throws CharacterCodingException(Code) | | Reads a 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 | abstract public String getString(int fieldSize, CharsetDecoder decoder) throws CharacterCodingException(Code) | | Reads a NUL -terminated string from this buffer using the
specified decoder and returns it.
Parameters: fieldSize - the maximum number of bytes to read |
getUnsigned | abstract public short getUnsigned()(Code) | | Reads one unsigned byte as a short integer.
|
getUnsigned | abstract public short getUnsigned(int index)(Code) | | Reads one byte as an unsigned short integer.
|
getUnsignedInt | abstract public long getUnsignedInt()(Code) | | Reads four bytes unsigned integer.
|
getUnsignedInt | abstract public long getUnsignedInt(int index)(Code) | | Reads four bytes unsigned integer.
|
getUnsignedMediumInt | abstract public int getUnsignedMediumInt()(Code) | | Relative get method for reading an unsigned medium int value.
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.
The unsigned medium int value at the buffer's current position |
getUnsignedMediumInt | abstract public int getUnsignedMediumInt(int index)(Code) | | Absolute get method for reading an unsigned medium int value.
Reads the next three bytes at this buffer's current position,
composing them into an int value according to the current byte order.
Parameters: index - The index from which the unsigned medium int will be read The unsigned medium int value at the given index throws: IndexOutOfBoundsException - If index is negativeor not smaller than the buffer's limit |
getUnsignedShort | abstract public int getUnsignedShort()(Code) | | Reads two bytes unsigned integer.
|
getUnsignedShort | abstract public int getUnsignedShort(int index)(Code) | | Reads two bytes unsigned integer.
|
hasArray | abstract public boolean hasArray()(Code) | | See Also: ByteBuffer.hasArray |
indexOf | abstract public int indexOf(byte b)(Code) | | Returns the first occurence position of the specified byte from the current position to
the current limit.
-1 if the specified byte is not found |
isAutoExpand | abstract public boolean isAutoExpand()(Code) | | Returns true if and only if autoExpand is turned on.
|
isAutoShrink | abstract public boolean isAutoShrink()(Code) | | Returns true if and only if autoShrink is turned on.
|
isDirect | abstract public boolean isDirect()(Code) | | See Also: ByteBuffer.isDirect |
isReadOnly | abstract public boolean isReadOnly()(Code) | | See Also: ByteBuffer.isReadOnly |
isUseDirectBuffer | public static boolean isUseDirectBuffer()(Code) | | Returns true if and only if a direct buffer is allocated
by default when the type of the new buffer is not specified. The
default value is false.
|
markValue | abstract public int markValue()(Code) | | Returns the position of the current mark. This method returns -1 if no
mark is set.
|
minimumCapacity | abstract public int minimumCapacity()(Code) | | 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. The default value is the initial capacity
of the buffer.
|
minimumCapacity | abstract public IoBuffer minimumCapacity(int minimumCapacity)(Code) | | 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. The default value is the initial capacity
of the buffer.
|
normalizeCapacity | protected static int normalizeCapacity(int requestedCapacity)(Code) | | Normalizes the specified capacity of the buffer to power of 2,
which is often helpful for optimal memory usage and performance.
If it is greater than or equal to
Integer.MAX_VALUE , it
returns
Integer.MAX_VALUE . If it is zero, it returns zero.
|
prefixedDataAvailable | abstract public boolean prefixedDataAvailable(int prefixLength)(Code) | | 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. This method is identical with
prefixedDataAvailable( prefixLength, Integer.MAX_VALUE ).
Please not that using this method can allow DoS (Denial of Service)
attack in case the remote peer sends too big data length value.
It is recommended to use
IoBuffer.prefixedDataAvailable(int,int) instead.
Parameters: prefixLength - the length of the prefix field (1, 2, or 4) throws: IllegalArgumentException - if prefixLength is wrong throws: BufferDataException - if data length is negative |
prefixedDataAvailable | abstract public boolean prefixedDataAvailable(int prefixLength, int maxDataLength)(Code) | | 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.
Parameters: prefixLength - the length of the prefix field (1, 2, or 4) Parameters: maxDataLength - the allowed maximum of the read data length throws: IllegalArgumentException - if prefixLength is wrong throws: BufferDataException - if data length is negative or greater then maxDataLength |
put | abstract public IoBuffer put(byte b)(Code) | | See Also: ByteBuffer.put(byte) |
put | abstract public IoBuffer put(int index, byte b)(Code) | | See Also: ByteBuffer.put(intbyte) |
put | abstract public IoBuffer put(ByteBuffer src)(Code) | | Writes the content of the specified src into this buffer.
|
put | abstract public IoBuffer put(byte[] src, int offset, int length)(Code) | | See Also: ByteBuffer.put(byte[]intint) |
put | abstract public IoBuffer put(byte[] src)(Code) | | See Also: ByteBuffer.put(byte[]) |
putChar | abstract public IoBuffer putChar(char value)(Code) | | See Also: ByteBuffer.putChar(char) |
putChar | abstract public IoBuffer putChar(int index, char value)(Code) | | See Also: ByteBuffer.putChar(intchar) |
putDouble | abstract public IoBuffer putDouble(double value)(Code) | | See Also: ByteBuffer.putDouble(double) |
putDouble | abstract public IoBuffer putDouble(int index, double value)(Code) | | See Also: ByteBuffer.putDouble(intdouble) |
putEnum | abstract public IoBuffer putEnum(Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as a byte.
Parameters: e - The enum to write to the buffer |
putEnum | abstract public IoBuffer putEnum(int index, Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as a byte.
Parameters: index - The index at which the byte will be written Parameters: e - The enum to write to the buffer |
putEnumInt | abstract public IoBuffer putEnumInt(Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as an integer.
Parameters: e - The enum to write to the buffer |
putEnumInt | abstract public IoBuffer putEnumInt(int index, Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as an integer.
Parameters: index - The index at which the bytes will be written Parameters: e - The enum to write to the buffer |
putEnumSet | abstract public IoBuffer putEnumSet(Set<E> set)(Code) | | Writes the specified
Set to the buffer as a byte sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: set - the enum set to write to the buffer |
putEnumSet | abstract public IoBuffer putEnumSet(int index, Set<E> set)(Code) | | Writes the specified
Set to the buffer as a byte sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: index - the index at which the byte will be written Parameters: set - the enum set to write to the buffer |
putEnumSetInt | abstract public IoBuffer putEnumSetInt(Set<E> set)(Code) | | Writes the specified
Set to the buffer as an int sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: set - the enum set to write to the buffer |
putEnumSetInt | abstract public IoBuffer putEnumSetInt(int index, Set<E> set)(Code) | | Writes the specified
Set to the buffer as an int sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: index - the index at which the bytes will be written Parameters: set - the enum set to write to the buffer |
putEnumSetLong | abstract public IoBuffer putEnumSetLong(Set<E> set)(Code) | | Writes the specified
Set to the buffer as a long sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: set - the enum set to write to the buffer |
putEnumSetLong | abstract public IoBuffer putEnumSetLong(int index, Set<E> set)(Code) | | Writes the specified
Set to the buffer as a long sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: index - the index at which the bytes will be written Parameters: set - the enum set to write to the buffer |
putEnumSetShort | abstract public IoBuffer putEnumSetShort(Set<E> set)(Code) | | Writes the specified
Set to the buffer as a short sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: set - the enum set to write to the buffer |
putEnumSetShort | abstract public IoBuffer putEnumSetShort(int index, Set<E> set)(Code) | | Writes the specified
Set to the buffer as a short sized bit vector.
< Parameters: E - > the enum type of the Set Parameters: index - the index at which the bytes will be written Parameters: set - the enum set to write to the buffer |
putEnumShort | abstract public IoBuffer putEnumShort(Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as a short.
Parameters: e - The enum to write to the buffer |
putEnumShort | abstract public IoBuffer putEnumShort(int index, Enum> e)(Code) | | Writes an enum's ordinal value to the buffer as a short.
Parameters: index - The index at which the bytes will be written Parameters: e - The enum to write to the buffer |
putFloat | abstract public IoBuffer putFloat(float value)(Code) | | See Also: ByteBuffer.putFloat(float) |
putFloat | abstract public IoBuffer putFloat(int index, float value)(Code) | | See Also: ByteBuffer.putFloat(intfloat) |
putInt | abstract public IoBuffer putInt(int value)(Code) | | See Also: ByteBuffer.putInt(int) |
putInt | abstract public IoBuffer putInt(int index, int value)(Code) | | See Also: ByteBuffer.putInt(intint) |
putLong | abstract public IoBuffer putLong(long value)(Code) | | See Also: ByteBuffer.putLong(intlong) |
putLong | abstract public IoBuffer putLong(int index, long value)(Code) | | See Also: ByteBuffer.putLong(intlong) |
putMediumInt | abstract public IoBuffer putMediumInt(int value)(Code) | | Relative put method for writing a medium 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.
Parameters: value - The medium int value to be written This buffer throws: BufferOverflowException - If there are fewer than three bytesremaining in this buffer throws: ReadOnlyBufferException - If this buffer is read-only |
putMediumInt | abstract public IoBuffer putMediumInt(int index, int value)(Code) | | Absolute put method for writing a medium int
value.
Writes three bytes containing the given int value, in the
current byte order, into this buffer at the given index.
Parameters: index - The index at which the bytes will be written Parameters: value - The medium int value to be written This buffer throws: IndexOutOfBoundsException - If index is negativeor not smaller than the buffer's limit,minus three throws: ReadOnlyBufferException - If this buffer is read-only |
putObject | abstract public IoBuffer putObject(Object o)(Code) | | Writes the specified Java object to the buffer.
|
putPrefixedString | abstract public IoBuffer putPrefixedString(CharSequence in, CharsetEncoder encoder) throws CharacterCodingException(Code) | | 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 .
This method is a shortcut for putPrefixedString(in, 2, 0, encoder).
throws: BufferOverflowException - if the specified string doesn't fit |
putPrefixedString | abstract public IoBuffer putPrefixedString(CharSequence in, int prefixLength, CharsetEncoder encoder) throws CharacterCodingException(Code) | | 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 .
This method is a shortcut for putPrefixedString(in, prefixLength, 0, encoder).
Parameters: prefixLength - the length of the length field (1, 2, or 4) throws: BufferOverflowException - if the specified string doesn't fit |
putPrefixedString | abstract public IoBuffer putPrefixedString(CharSequence in, int prefixLength, int padding, CharsetEncoder encoder) throws CharacterCodingException(Code) | | 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 .
This method is a shortcut for putPrefixedString(in, prefixLength, padding, ( byte ) 0, encoder).
Parameters: prefixLength - the length of the length field (1, 2, or 4) Parameters: padding - the number of padded NULs (1 (or 0), 2, or 4) throws: BufferOverflowException - if the specified string doesn't fit |
putPrefixedString | abstract public IoBuffer putPrefixedString(CharSequence val, int prefixLength, int padding, byte padValue, CharsetEncoder encoder) throws CharacterCodingException(Code) | | 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 .
Parameters: prefixLength - the length of the length field (1, 2, or 4) Parameters: padding - the number of padded bytes (1 (or 0), 2, or 4) Parameters: padValue - the value of padded bytes throws: BufferOverflowException - if the specified string doesn't fit |
putShort | abstract public IoBuffer putShort(short value)(Code) | | See Also: ByteBuffer.putShort(short) |
putShort | abstract public IoBuffer putShort(int index, short value)(Code) | | See Also: ByteBuffer.putShort(intshort) |
putString | abstract public IoBuffer putString(CharSequence val, CharsetEncoder encoder) throws CharacterCodingException(Code) | | Writes the content of in into this buffer using the
specified encoder . This method doesn't terminate
string with NUL. You have to do it by yourself.
throws: BufferOverflowException - if the specified string doesn't fit |
putString | abstract public IoBuffer putString(CharSequence val, int fieldSize, CharsetEncoder encoder) throws CharacterCodingException(Code) | | Writes the content of 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.
Parameters: fieldSize - the maximum number of bytes to write |
setAllocator | public static void setAllocator(IoBufferAllocator newAllocator)(Code) | | Sets the allocator used by existing and new buffers
|
setAutoExpand | abstract public IoBuffer setAutoExpand(boolean autoExpand)(Code) | | Turns on or off autoExpand.
|
setAutoShrink | abstract public IoBuffer setAutoShrink(boolean autoShrink)(Code) | | Turns on or off autoShrink.
|
setUseDirectBuffer | public static void setUseDirectBuffer(boolean useDirectBuffer)(Code) | | Sets if a direct buffer should be allocated by default when the
type of the new buffer is not specified. The default value is
false.
|
shrink | abstract public IoBuffer shrink()(Code) | | 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. The capacity of the
buffer never becomes less than
IoBuffer.minimumCapacity() .
The mark is discarded once the capacity changes.
|
skip | abstract public IoBuffer skip(int size)(Code) | | Forwards the position of this buffer as the specified size
bytes.
|
sweep | abstract public IoBuffer sweep()(Code) | | Clears this buffer and fills its content with NUL.
The position is set to zero, the limit is set to the capacity,
and the mark is discarded.
|
sweep | abstract public IoBuffer sweep(byte value)(Code) | | Clears this buffer and fills its content with value.
The position is set to zero, the limit is set to the capacity,
and the mark is discarded.
|
wrap | public static IoBuffer wrap(ByteBuffer nioBuffer)(Code) | | Wraps the specified NIO
ByteBuffer into MINA buffer.
|
wrap | public static IoBuffer wrap(byte[] byteArray)(Code) | | Wraps the specified byte array into MINA heap buffer.
|
wrap | public static IoBuffer wrap(byte[] byteArray, int offset, int length)(Code) | | Wraps the specified byte array into MINA heap buffer.
|
|
|