Class IoBuffer

  • All Implemented Interfaces:
    Comparable<IoBuffer>
    Direct Known Subclasses:
    AbstractIoBuffer, IoBufferWrapper

    public abstract class IoBuffer
    extends Object
    implements Comparable<IoBuffer>
    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 at allocation. IoBuffer introduces the autoExpand property. If autoExpand property is set to true, you never get a BufferOverflowException or an IndexOutOfBoundsException (except when index is negative). It automatically expands its capacity. For instance:

         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 compact() is invoked and only 1/4 or less of the current capacity is being used.

    You can also call the shrink() method manually to shrink the capacity of the buffer.

    The underlying ByteBuffer is reallocated by the IoBuffer behind the scene, and therefore buf() will return a different ByteBuffer instance once capacity changes. Please also note that the compact() method or the shrink() method will not decrease the capacity if the new capacity is less than the minimumCapacity() of the buffer.

    Derived Buffers

    Derived buffers are the buffers which were created by the duplicate(), slice(), or asReadOnlyBuffer() methods. They are useful especially when you broadcast the same messages to multiple IoSessions. Please note that the buffer derived from and its derived buffers are not auto-expandable nor auto-shrinkable. Trying to call setAutoExpand(boolean) or setAutoShrink(boolean) with true parameter will raise an IllegalStateException.

    Changing Buffer Allocation Policy

    The 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 setAllocator(IoBufferAllocator).
    Author:
    Apache MINA Project
    • Constructor Detail

      • IoBuffer

        protected IoBuffer()
        Creates a new instance. This is an empty constructor. It's protected, to forbid its usage by the users.
    • Method Detail

      • getAllocator

        public static IoBufferAllocator getAllocator()
        Returns:
        the allocator used by existing and new buffers
      • setAllocator

        public static void setAllocator​(IoBufferAllocator newAllocator)
        Sets the allocator used by existing and new buffers
        Parameters:
        newAllocator - the new allocator to use
      • isUseDirectBuffer

        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. The default value is false.
      • setUseDirectBuffer

        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. The default value is false.
        Parameters:
        useDirectBuffer - Tells if direct buffers should be allocated
      • allocate

        public static IoBuffer allocate​(int capacity)
        Returns the direct or heap buffer which is capable to store the specified amount of bytes.
        Parameters:
        capacity - the capacity of the buffer
        Returns:
        a IoBuffer which can hold up to capacity bytes
        See Also:
        setUseDirectBuffer(boolean)
      • allocate

        public static IoBuffer allocate​(int capacity,
                                        boolean useDirectBuffer)
        Returns a direct or heap IoBuffer which can contain the specified number of bytes.
        Parameters:
        capacity - the capacity of the buffer
        useDirectBuffer - true to get a direct buffer, false to get a heap buffer.
        Returns:
        a direct or heap IoBuffer which can hold up to capacity bytes
      • wrap

        public static IoBuffer wrap​(ByteBuffer nioBuffer)
        Wraps the specified NIO ByteBuffer into a MINA buffer (either direct or heap).
        Parameters:
        nioBuffer - The ByteBuffer to wrap
        Returns:
        a IoBuffer containing the bytes stored in the ByteBuffer
      • wrap

        public static IoBuffer wrap​(byte[] byteArray)
        Wraps the specified byte array into a MINA heap buffer. Note that the byte array is not copied, so any modification done on it will be visible by both sides.
        Parameters:
        byteArray - The byte array to wrap
        Returns:
        a heap IoBuffer containing the byte array
      • wrap

        public static IoBuffer wrap​(byte[] byteArray,
                                    int offset,
                                    int length)
        Wraps the specified byte array into MINA heap buffer. We just wrap the bytes starting from offset up to offset + length. Note that the byte array is not copied, so any modification done on it will be visible by both sides.
        Parameters:
        byteArray - The byte array to wrap
        offset - The starting point in the byte array
        length - The number of bytes to store
        Returns:
        a heap IoBuffer containing the selected part of the byte array
      • normalizeCapacity

        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. If it is greater than or equal to Integer.MAX_VALUE, it returns Integer.MAX_VALUE. If it is zero, it returns zero.
        Parameters:
        requestedCapacity - The IoBuffer capacity we want to be able to store
        Returns:
        The power of 2 strictly superior to the requested capacity
      • free

        public abstract 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.
      • isDirect

        public abstract boolean isDirect()
        Returns:
        True if this is a direct buffer
        See Also:
        ByteBuffer.isDirect()
      • isDerived

        public abstract boolean isDerived()
        Returns:
        true if and only if this buffer is derived from another buffer via one of the duplicate(), slice() or asReadOnlyBuffer() methods.
      • isReadOnly

        public abstract boolean isReadOnly()
        Returns:
        true if the buffer is readOnly
        See Also:
        Buffer.isReadOnly()
      • minimumCapacity

        public abstract int minimumCapacity()
        Returns:
        the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk by the compact() and shrink() operation. The default value is the initial capacity of the buffer.
      • minimumCapacity

        public abstract IoBuffer minimumCapacity​(int minimumCapacity)
        Sets the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk by compact() and shrink() operation. The default value is the initial capacity of the buffer.
        Parameters:
        minimumCapacity - the wanted minimum capacity
        Returns:
        the underlying NIO ByteBuffer instance.
      • capacity

        public abstract int capacity()
        Returns:
        the buffer capacity
        See Also:
        Buffer.capacity()
      • capacity

        public abstract IoBuffer capacity​(int newCapacity)
        Increases the capacity of this buffer. If the new capacity is less than or equal to the current capacity, this method returns the original buffer. 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.
        Note that the IoBuffer is replaced, it's not copied.
        Assuming a buffer contains N bytes, its position is 0 and its current capacity is C, here are the resulting buffer if we set the new capacity to a value V < C and V > C :
          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.
          
         
        Parameters:
        newCapacity - the wanted capacity
        Returns:
        the underlying NIO ByteBuffer instance.
      • isAutoExpand

        public abstract boolean isAutoExpand()
        Returns:
        true if and only if autoExpand is turned on.
      • setAutoExpand

        public abstract IoBuffer setAutoExpand​(boolean autoExpand)
        Turns on or off autoExpand.
        Parameters:
        autoExpand - The flag value to set
        Returns:
        The modified IoBuffer instance
      • isAutoShrink

        public abstract boolean isAutoShrink()
        Returns:
        true if and only if autoShrink is turned on.
      • setAutoShrink

        public abstract IoBuffer setAutoShrink​(boolean autoShrink)
        Turns on or off autoShrink.
        Parameters:
        autoShrink - The flag value to set
        Returns:
        The modified IoBuffer instance
      • expand

        public abstract IoBuffer expand​(int expectedRemaining)
        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.
        Assuming a buffer contains N bytes, its position is P and its current capacity is C, here are the resulting buffer if we call the expand method with a expectedRemaining value V :
          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.
        Parameters:
        expectedRemaining - The expected remaining bytes in the buffer
        Returns:
        The modified IoBuffer instance
      • expand

        public abstract 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. This method works even if you didn't set autoExpand to true. Assuming a buffer contains N bytes, its position is P and its current capacity is C, here are the resulting buffer if we call the expand method with a expectedRemaining value V :
          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.
        Parameters:
        position - The starting position from which we want to define a remaining number of bytes
        expectedRemaining - The expected remaining bytes in the buffer
        Returns:
        The modified IoBuffer instance
      • shrink

        public abstract 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.
        The capacity of the buffer never becomes less than minimumCapacity()
        . The mark is discarded once the capacity changes.
        Typically, a call to this method tries to remove as much unused bytes as possible, dividing by two the initial capacity until it can't without obtaining a new capacity lower than the 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
         
        Returns:
        The modified IoBuffer instance
      • position

        public abstract int position()
        Returns:
        The current position in the buffer
        See Also:
        Buffer.position()
      • position

        public abstract IoBuffer position​(int newPosition)
        Parameters:
        newPosition - Sets the new position in the buffer
        Returns:
        the modified IoBuffer
        See Also:
        Buffer.position(int)
      • limit

        public abstract int limit()
        Returns:
        the modified IoBuffer 's limit
        See Also:
        Buffer.limit()
      • limit

        public abstract IoBuffer limit​(int newLimit)
        Parameters:
        newLimit - The new buffer's limit
        Returns:
        the modified IoBuffer
        See Also:
        Buffer.limit(int)
      • markValue

        public abstract int markValue()
        Returns:
        the position of the current mark. This method returns -1 if no mark is set.
      • sweep

        public abstract IoBuffer sweep()
        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.
        Returns:
        the modified IoBuffer
      • sweep

        public abstract IoBuffer sweep​(byte value)
        double 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.
        Parameters:
        value - The value to put in the buffer
        Returns:
        the modified IoBuffer
      • remaining

        public abstract int remaining()
        Returns:
        The remaining bytes in the buffer
        See Also:
        Buffer.remaining()
      • hasRemaining

        public abstract boolean hasRemaining()
        Returns:
        true if there are some remaining bytes in the buffer
        See Also:
        Buffer.hasRemaining()
      • array

        public abstract byte[] array()
        Returns:
        A byte[] if this IoBuffer supports it
        See Also:
        ByteBuffer.array()
      • arrayOffset

        public abstract int arrayOffset()
        Returns:
        The offset in the returned byte[] when the array() method is called
        See Also:
        ByteBuffer.arrayOffset()
      • get

        public abstract byte get()
        Returns:
        The byte at the current position
        See Also:
        ByteBuffer.get()
      • getUnsigned

        public abstract short getUnsigned()
        Reads one unsigned byte as a short integer.
        Returns:
        the unsigned short at the current position
      • put

        public abstract IoBuffer put​(byte b)
        Parameters:
        b - The byte to put in the buffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.put(byte)
      • get

        public abstract byte get​(int index)
        Parameters:
        index - The position for which we want to read a byte
        Returns:
        the byte at the given position
        See Also:
        ByteBuffer.get(int)
      • getUnsigned

        public abstract short getUnsigned​(int index)
        Reads one byte as an unsigned short integer.
        Parameters:
        index - The position for which we want to read an unsigned byte
        Returns:
        the unsigned byte at the given position
      • put

        public abstract IoBuffer put​(int index,
                                     byte b)
        Parameters:
        index - The position where the byte will be put
        b - The byte to put
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.put(int, byte)
      • get

        public abstract IoBuffer get​(byte[] dst,
                                     int offset,
                                     int length)
        Parameters:
        dst - The destination buffer
        offset - The position in the original buffer
        length - The number of bytes to copy
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.get(byte[], int, int)
      • get

        public abstract IoBuffer get​(byte[] dst)
        Parameters:
        dst - The byte[] that will contain the read bytes
        Returns:
        the IoBuffer
        See Also:
        ByteBuffer.get(byte[])
      • getSlice

        public abstract IoBuffer getSlice​(int index,
                                          int length)
        Get a new IoBuffer containing a slice of the current buffer
        Parameters:
        index - The position in the buffer
        length - The number of bytes to copy
        Returns:
        the new IoBuffer
      • getSlice

        public abstract IoBuffer getSlice​(int length)
        Get a new IoBuffer containing a slice of the current buffer
        Parameters:
        length - The number of bytes to copy
        Returns:
        the new IoBuffer
      • put

        public abstract IoBuffer put​(ByteBuffer src)
        Writes the content of the specified src into this buffer.
        Parameters:
        src - The source ByteBuffer
        Returns:
        the modified IoBuffer
      • put

        public abstract IoBuffer put​(IoBuffer src)
        Writes the content of the specified src into this buffer.
        Parameters:
        src - The source IoBuffer
        Returns:
        the modified IoBuffer
      • put

        public abstract IoBuffer put​(byte[] src,
                                     int offset,
                                     int length)
        Parameters:
        src - The byte[] to put
        offset - The position in the source
        length - The number of bytes to copy
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.put(byte[], int, int)
      • put

        public abstract IoBuffer put​(byte[] src)
        Parameters:
        src - The byte[] to put
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.put(byte[])
      • getChar

        public abstract char getChar()
        Returns:
        The char at the current position
        See Also:
        ByteBuffer.getChar()
      • putChar

        public abstract IoBuffer putChar​(char value)
        Parameters:
        value - The char to put at the current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putChar(char)
      • getChar

        public abstract char getChar​(int index)
        Parameters:
        index - The index in the IoBuffer where we will read a char from
        Returns:
        the char at 'index' position
        See Also:
        ByteBuffer.getChar(int)
      • putChar

        public abstract IoBuffer putChar​(int index,
                                         char value)
        Parameters:
        index - The index in the IoBuffer where we will put a char in
        value - The char to put at the current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putChar(int, char)
      • getUnsignedShort

        public abstract int getUnsignedShort()
        Reads two bytes unsigned integer.
        Returns:
        The read unsigned short
      • putShort

        public abstract IoBuffer putShort​(short value)
        Parameters:
        value - The short to put at the current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putShort(short)
      • getShort

        public abstract short getShort​(int index)
        Parameters:
        index - The index in the IoBuffer where we will read a short from
        Returns:
        The read short
        See Also:
        ByteBuffer.getShort()
      • getUnsignedShort

        public abstract int getUnsignedShort​(int index)
        Reads two bytes unsigned integer.
        Parameters:
        index - The index in the IoBuffer where we will read an unsigned short from
        Returns:
        the unsigned short at the given position
      • putShort

        public abstract IoBuffer putShort​(int index,
                                          short value)
        Parameters:
        index - The position at which the short should be written
        value - The short to put at the current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putShort(int, short)
      • getUnsignedInt

        public abstract long getUnsignedInt()
        Reads four bytes unsigned integer.
        Returns:
        The unsigned int read
      • getMediumInt

        public abstract int getMediumInt()
        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.

        Returns:
        The medium int value at the buffer's current position
      • getUnsignedMediumInt

        public abstract int getUnsignedMediumInt()
        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.

        Returns:
        The unsigned medium int value at the buffer's current position
      • getMediumInt

        public abstract int getMediumInt​(int index)
        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
        Returns:
        The medium int value at the given index
        Throws:
        IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit
      • getUnsignedMediumInt

        public abstract int getUnsignedMediumInt​(int index)
        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
        Returns:
        The unsigned medium int value at the given index
        Throws:
        IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit
      • putMediumInt

        public abstract IoBuffer putMediumInt​(int value)
        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
        Returns:
        the modified IoBuffer
      • putMediumInt

        public abstract IoBuffer putMediumInt​(int index,
                                              int value)
        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
        value - The medium int value to be written
        Returns:
        the modified IoBuffer
        Throws:
        IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit, minus three
      • putInt

        public abstract IoBuffer putInt​(int value)
        Parameters:
        value - The int to put at the current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putInt(int)
      • putUnsigned

        public abstract IoBuffer putUnsigned​(byte value)
        Writes an unsigned byte into the ByteBuffer
        Parameters:
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(int index,
                                             byte value)
        Writes an unsigned byte into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(short value)
        Writes an unsigned byte into the ByteBuffer
        Parameters:
        value - the short to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(int index,
                                             short value)
        Writes an unsigned byte into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the short to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(int value)
        Writes an unsigned byte into the ByteBuffer
        Parameters:
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(int index,
                                             int value)
        Writes an unsigned byte into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(long value)
        Writes an unsigned byte into the ByteBuffer
        Parameters:
        value - the long to write
        Returns:
        the modified IoBuffer
      • putUnsigned

        public abstract IoBuffer putUnsigned​(int index,
                                             long value)
        Writes an unsigned byte into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the long to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(byte value)
        Writes an unsigned int into the ByteBuffer
        Parameters:
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(int index,
                                                byte value)
        Writes an unsigned int into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(short value)
        Writes an unsigned int into the ByteBuffer
        Parameters:
        value - the short to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(int index,
                                                short value)
        Writes an unsigned int into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the short to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(int value)
        Writes an unsigned int into the ByteBuffer
        Parameters:
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(int index,
                                                int value)
        Writes an unsigned int into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(long value)
        Writes an unsigned int into the ByteBuffer
        Parameters:
        value - the long to write
        Returns:
        the modified IoBuffer
      • putUnsignedInt

        public abstract IoBuffer putUnsignedInt​(int index,
                                                long value)
        Writes an unsigned int into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the long to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(byte value)
        Writes an unsigned short into the ByteBuffer
        Parameters:
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(int index,
                                                  byte value)
        Writes an unsigned Short into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the byte to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(short value)
        Writes an unsigned Short into the ByteBuffer
        Parameters:
        value - the short to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(int index,
                                                  short value)
        Writes an unsigned Short into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the unsigned short
        value - the unsigned short to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(int value)
        Writes an unsigned Short into the ByteBuffer
        Parameters:
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(int index,
                                                  int value)
        Writes an unsigned Short into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the value
        value - the int to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(long value)
        Writes an unsigned Short into the ByteBuffer
        Parameters:
        value - the long to write
        Returns:
        the modified IoBuffer
      • putUnsignedShort

        public abstract IoBuffer putUnsignedShort​(int index,
                                                  long value)
        Writes an unsigned Short into the ByteBuffer at a specified position
        Parameters:
        index - the position in the buffer to write the short
        value - the long to write
        Returns:
        the modified IoBuffer
      • getInt

        public abstract int getInt​(int index)
        Parameters:
        index - The index in the IoBuffer where we will read an int from
        Returns:
        the int at the given position
        See Also:
        ByteBuffer.getInt(int)
      • getUnsignedInt

        public abstract long getUnsignedInt​(int index)
        Reads four bytes unsigned integer.
        Parameters:
        index - The index in the IoBuffer where we will read an unsigned int from
        Returns:
        The long at the given position
      • putInt

        public abstract IoBuffer putInt​(int index,
                                        int value)
        Parameters:
        index - The position where to put the int
        value - The int to put in the IoBuffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putInt(int, int)
      • getLong

        public abstract long getLong()
        Returns:
        The long at the current position
        See Also:
        ByteBuffer.getLong()
      • getLong

        public abstract long getLong​(int index)
        Parameters:
        index - The index in the IoBuffer where we will read a long from
        Returns:
        the long at the given position
        See Also:
        ByteBuffer.getLong(int)
      • putLong

        public abstract IoBuffer putLong​(int index,
                                         long value)
        Parameters:
        index - The position where to put the long
        value - The long to put in the IoBuffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putLong(int, long)
      • getFloat

        public abstract float getFloat()
        Returns:
        the float at the current position
        See Also:
        ByteBuffer.getFloat()
      • putFloat

        public abstract IoBuffer putFloat​(float value)
        Parameters:
        value - The float to put in the IoBuffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putFloat(float)
      • getFloat

        public abstract float getFloat​(int index)
        Parameters:
        index - The index in the IoBuffer where we will read a float from
        Returns:
        The float at the given position
        See Also:
        ByteBuffer.getFloat(int)
      • putFloat

        public abstract IoBuffer putFloat​(int index,
                                          float value)
        Parameters:
        index - The position where to put the float
        value - The float to put in the IoBuffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putFloat(int, float)
      • getDouble

        public abstract double getDouble()
        Returns:
        the double at the current position
        See Also:
        ByteBuffer.getDouble()
      • putDouble

        public abstract IoBuffer putDouble​(double value)
        Parameters:
        value - The double to put at the IoBuffer current position
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putDouble(double)
      • getDouble

        public abstract double getDouble​(int index)
        Parameters:
        index - The position where to get the double from
        Returns:
        The double at the given position
        See Also:
        ByteBuffer.getDouble(int)
      • putDouble

        public abstract IoBuffer putDouble​(int index,
                                           double value)
        Parameters:
        index - The position where to put the double
        value - The double to put in the IoBuffer
        Returns:
        the modified IoBuffer
        See Also:
        ByteBuffer.putDouble(int, double)
      • getHexDump

        public abstract String getHexDump()
        Returns hexdump of this buffer. The data and pointer are not changed as a result of this method call.
        Returns:
        hexidecimal representation of this buffer
      • getHexDump

        public abstract String getHexDump​(int lengthLimit)
        Return hexdump of this buffer with limited length.
        Parameters:
        lengthLimit - The maximum number of bytes to dump from the current buffer position.
        Returns:
        hexidecimal representation of this buffer
      • getString

        public abstract String getString​(CharsetDecoder decoder)
                                  throws CharacterCodingException
        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.
        Parameters:
        decoder - The CharsetDecoder to use
        Returns:
        the read String
        Throws:
        CharacterCodingException - Thrown when an error occurred while decoding the buffer
      • getString

        public abstract String getString​(int fieldSize,
                                         CharsetDecoder decoder)
                                  throws CharacterCodingException
        Reads a NUL-terminated string from this buffer using the specified decoder and returns it.
        Parameters:
        fieldSize - the maximum number of bytes to read
        decoder - The CharsetDecoder to use
        Returns:
        the read String
        Throws:
        CharacterCodingException - Thrown when an error occurred while decoding the buffer
      • putString

        public abstract IoBuffer putString​(CharSequence val,
                                           CharsetEncoder encoder)
                                    throws CharacterCodingException
        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.
        Parameters:
        val - The CharSequence to put in the IoBuffer
        encoder - The CharsetEncoder to use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the String
      • putString

        public abstract IoBuffer putString​(CharSequence val,
                                           int fieldSize,
                                           CharsetEncoder encoder)
                                    throws CharacterCodingException
        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 NULs as a terminator.

        Please note that this method doesn't terminate with NUL if the input string is longer than fieldSize.

        Parameters:
        val - The CharSequence to put in the IoBuffer
        fieldSize - the maximum number of bytes to write
        encoder - The CharsetEncoder to use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the String
      • getPrefixedString

        public abstract String getPrefixedString​(CharsetDecoder decoder)
                                          throws CharacterCodingException
        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).
        Parameters:
        decoder - The CharsetDecoder to use
        Returns:
        The read String
        Throws:
        CharacterCodingException - When we have an error while decoding the String
      • getPrefixedString

        public abstract String getPrefixedString​(int prefixLength,
                                                 CharsetDecoder decoder)
                                          throws CharacterCodingException
        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)
        decoder - The CharsetDecoder to use
        Returns:
        The read String
        Throws:
        CharacterCodingException - When we have an error while decoding the String
      • putPrefixedString

        public abstract IoBuffer putPrefixedString​(CharSequence in,
                                                   CharsetEncoder encoder)
                                            throws CharacterCodingException
        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).
        Parameters:
        in - The CharSequence to put in the IoBuffer
        encoder - The CharsetEncoder to use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the CharSequence
      • putPrefixedString

        public abstract IoBuffer putPrefixedString​(CharSequence in,
                                                   int prefixLength,
                                                   CharsetEncoder encoder)
                                            throws CharacterCodingException
        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:
        in - The CharSequence to put in the IoBuffer
        prefixLength - the length of the length field (1, 2, or 4)
        encoder - The CharsetEncoder to use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the CharSequence
      • putPrefixedString

        public abstract IoBuffer putPrefixedString​(CharSequence in,
                                                   int prefixLength,
                                                   int padding,
                                                   CharsetEncoder encoder)
                                            throws CharacterCodingException
        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:
        in - The CharSequence to put in the IoBuffer
        prefixLength - 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 use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the CharSequence
      • putPrefixedString

        public abstract IoBuffer putPrefixedString​(CharSequence val,
                                                   int prefixLength,
                                                   int padding,
                                                   byte padValue,
                                                   CharsetEncoder encoder)
                                            throws CharacterCodingException
        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.
        Parameters:
        val - The CharSequence to put in teh 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 bytes
        encoder - The CharsetEncoder to use
        Returns:
        The modified IoBuffer
        Throws:
        CharacterCodingException - When we have an error while decoding the CharSequence
      • getObject

        public abstract Object getObject​(ClassLoader classLoader)
                                  throws ClassNotFoundException
        Reads a Java object from the buffer using the specified classLoader.
        Parameters:
        classLoader - The classLoader to use to read an Object from the IoBuffer
        Returns:
        The read Object
        Throws:
        ClassNotFoundException - thrown when we can't find the Class to use
      • putObject

        public abstract IoBuffer putObject​(Object o)
        Writes the specified Java object to the buffer.
        Parameters:
        o - The Object to write in the IoBuffer
        Returns:
        The modified IoBuffer
      • prefixedDataAvailable

        public abstract boolean prefixedDataAvailable​(int prefixLength)
        Parameters:
        prefixLength - the length of the prefix field (1, 2, or 4)
        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 prefixedDataAvailable(int, int) instead.
        Throws:
        IllegalArgumentException - if prefixLength is wrong
        BufferDataException - if data length is negative
      • prefixedDataAvailable

        public abstract boolean prefixedDataAvailable​(int prefixLength,
                                                      int maxDataLength)
        Parameters:
        prefixLength - the length of the prefix field (1, 2, or 4)
        maxDataLength - the allowed maximum of the read data length
        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.
        Throws:
        IllegalArgumentException - if prefixLength is wrong
        BufferDataException - if data length is negative or greater then maxDataLength
      • indexOf

        public abstract int indexOf​(byte b)
        Returns the first occurrence position of the specified byte from the current position to the current limit.
        Parameters:
        b - The byte we are looking for
        Returns:
        -1 if the specified byte is not found
      • skip

        public abstract IoBuffer skip​(int size)
        Forwards the position of this buffer as the specified size bytes.
        Parameters:
        size - The added size
        Returns:
        The modified IoBuffer
      • fill

        public abstract IoBuffer fill​(byte value,
                                      int size)
        Fills this buffer with the specified value. This method moves buffer position forward.
        Parameters:
        value - The value to fill the IoBuffer with
        size - The added size
        Returns:
        The modified IoBuffer
      • fillAndReset

        public abstract IoBuffer fillAndReset​(byte value,
                                              int size)
        Fills this buffer with the specified value. This method does not change buffer position.
        Parameters:
        value - The value to fill the IoBuffer with
        size - The added size
        Returns:
        The modified IoBuffer
      • fill

        public abstract IoBuffer fill​(int size)
        Fills this buffer with NUL (0x00). This method moves buffer position forward.
        Parameters:
        size - The added size
        Returns:
        The modified IoBuffer
      • fillAndReset

        public abstract IoBuffer fillAndReset​(int size)
        Fills this buffer with NUL (0x00). This method does not change buffer position.
        Parameters:
        size - The added size
        Returns:
        The modified IoBuffer
      • getEnum

        public abstract <E extends Enum<E>> E getEnum​(Class<E> enumClass)
        Reads a byte from the buffer and returns the correlating enum constant defined by the specified enum type.
        Type Parameters:
        E - The enum type to return
        Parameters:
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • getEnum

        public abstract <E extends Enum<E>> 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.
        Type Parameters:
        E - The enum type to return
        Parameters:
        index - the index from which the byte will be read
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • getEnumShort

        public abstract <E extends Enum<E>> E getEnumShort​(Class<E> enumClass)
        Reads a short from the buffer and returns the correlating enum constant defined by the specified enum type.
        Type Parameters:
        E - The enum type to return
        Parameters:
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • getEnumShort

        public abstract <E extends Enum<E>> 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.
        Type Parameters:
        E - The enum type to return
        Parameters:
        index - the index from which the bytes will be read
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • getEnumInt

        public abstract <E extends Enum<E>> E getEnumInt​(Class<E> enumClass)
        Reads an int from the buffer and returns the correlating enum constant defined by the specified enum type.
        Type Parameters:
        E - The enum type to return
        Parameters:
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • getEnumInt

        public abstract <E extends Enum<E>> 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.
        Type Parameters:
        E - The enum type to return
        Parameters:
        index - the index from which the bytes will be read
        enumClass - The enum's class object
        Returns:
        The correlated enum constant
      • putEnum

        public abstract IoBuffer putEnum​(Enum<?> e)
        Writes an enum's ordinal value to the buffer as a byte.
        Parameters:
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • putEnum

        public abstract IoBuffer putEnum​(int index,
                                         Enum<?> e)
        Writes an enum's ordinal value to the buffer as a byte.
        Parameters:
        index - The index at which the byte will be written
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • putEnumShort

        public abstract IoBuffer putEnumShort​(Enum<?> e)
        Writes an enum's ordinal value to the buffer as a short.
        Parameters:
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • putEnumShort

        public abstract IoBuffer putEnumShort​(int index,
                                              Enum<?> e)
        Writes an enum's ordinal value to the buffer as a short.
        Parameters:
        index - The index at which the bytes will be written
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • putEnumInt

        public abstract IoBuffer putEnumInt​(Enum<?> e)
        Writes an enum's ordinal value to the buffer as an integer.
        Parameters:
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • putEnumInt

        public abstract IoBuffer putEnumInt​(int index,
                                            Enum<?> e)
        Writes an enum's ordinal value to the buffer as an integer.
        Parameters:
        index - The index at which the bytes will be written
        e - The enum to write to the buffer
        Returns:
        The modified IoBuffer
      • getEnumSet

        public abstract <E extends Enum<E>> Set<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. 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.

        Type Parameters:
        E - the enum type
        Parameters:
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
      • getEnumSet

        public abstract <E extends Enum<E>> Set<E> getEnumSet​(int index,
                                                              Class<E> enumClass)
        Reads a byte sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        index - the index from which the byte will be read
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetShort

        public abstract <E extends Enum<E>> Set<E> getEnumSetShort​(Class<E> enumClass)
        Reads a short sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetShort

        public abstract <E extends Enum<E>> Set<E> getEnumSetShort​(int index,
                                                                   Class<E> enumClass)
        Reads a short sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        index - the index from which the bytes will be read
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetInt

        public abstract <E extends Enum<E>> Set<E> getEnumSetInt​(Class<E> enumClass)
        Reads an int sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetInt

        public abstract <E extends Enum<E>> Set<E> getEnumSetInt​(int index,
                                                                 Class<E> enumClass)
        Reads an int sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        index - the index from which the bytes will be read
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetLong

        public abstract <E extends Enum<E>> Set<E> getEnumSetLong​(Class<E> enumClass)
        Reads a long sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • getEnumSetLong

        public abstract <E extends Enum<E>> Set<E> getEnumSetLong​(int index,
                                                                  Class<E> enumClass)
        Reads a long sized bit vector and converts it to an EnumSet.
        Type Parameters:
        E - the enum type
        Parameters:
        index - the index from which the bytes will be read
        enumClass - the enum class used to create the EnumSet
        Returns:
        the EnumSet representation of the bit vector
        See Also:
        getEnumSet(Class)
      • putEnumSet

        public abstract <E extends Enum<E>> IoBuffer putEnumSet​(Set<E> set)
        Writes the specified Set to the buffer as a byte sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSet

        public abstract <E extends Enum<E>> IoBuffer putEnumSet​(int index,
                                                                Set<E> set)
        Writes the specified Set to the buffer as a byte sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        index - the index at which the byte will be written
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetShort

        public abstract <E extends Enum<E>> IoBuffer putEnumSetShort​(Set<E> set)
        Writes the specified Set to the buffer as a short sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetShort

        public abstract <E extends Enum<E>> IoBuffer putEnumSetShort​(int index,
                                                                     Set<E> set)
        Writes the specified Set to the buffer as a short sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        index - the index at which the bytes will be written
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetInt

        public abstract <E extends Enum<E>> IoBuffer putEnumSetInt​(Set<E> set)
        Writes the specified Set to the buffer as an int sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetInt

        public abstract <E extends Enum<E>> IoBuffer putEnumSetInt​(int index,
                                                                   Set<E> set)
        Writes the specified Set to the buffer as an int sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        index - the index at which the bytes will be written
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetLong

        public abstract <E extends Enum<E>> IoBuffer putEnumSetLong​(Set<E> set)
        Writes the specified Set to the buffer as a long sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer
      • putEnumSetLong

        public abstract <E extends Enum<E>> IoBuffer putEnumSetLong​(int index,
                                                                    Set<E> set)
        Writes the specified Set to the buffer as a long sized bit vector.
        Type Parameters:
        E - the enum type of the Set
        Parameters:
        index - the index at which the bytes will be written
        set - the enum set to write to the buffer
        Returns:
        the modified IoBuffer