Class ByteBuffer

java.lang.Object
com.epam.common.utils.ByteBuffer

public final class ByteBuffer extends Object
The byte buffer helper class.
  • Field Details

  • Constructor Details

    • ByteBuffer

      public ByteBuffer()
      Creates the ByteBuffer with allocated byte buffer. The default buffer length if 1024 bytes.
    • ByteBuffer

      public ByteBuffer(int length)
      Creates the ByteBuffer with allocated byte buffer.
      Parameters:
      length - allocated buffer length
    • ByteBuffer

      public ByteBuffer(int length, boolean useNIOBuffer)
    • ByteBuffer

      public ByteBuffer(int length, int growIncrement)
    • ByteBuffer

      public ByteBuffer(int size, int growIncrement, boolean useNIOBuffer)
      Parameters:
      size - buffer size in bytes
      growIncrement - grow size in bytes
      useNIOBuffer -
  • Method Details

    • getBuffer

      public ByteBuffer getBuffer()
    • addLikeString

      public ByteBuffer addLikeString(long value)
    • checkAndExtend

      public void checkAndExtend(int length)
    • add

      public ByteBuffer add(String s)
    • put

      public ByteBuffer put(String s)
    • add

      public ByteBuffer add(byte[] array)
      Appends the array argument to internal buffer.
      Returns:
      a reference to this object.
    • add

      public ByteBuffer add(byte b)
      Adds byte to buffer.
      Parameters:
      b - a byte
    • add

      public ByteBuffer add(char b)
      Adds char to buffer.
      Parameters:
      b - a char
    • add

      public ByteBuffer add(byte[] array, int start, int len)
      Appends the array argument to internal buffer.
      Returns:
      a reference to this object.
    • add

      public ByteBuffer add(ByteBuffer buffer)
    • add

      public ByteBuffer add(ByteBuffer buffer)
    • isAvailable

      public boolean isAvailable(int length)
      Checks if buffer has a numOfBytes.
      Parameters:
      length - the requested space
      Returns:
      boolean true if has
    • setOffset

      public void setOffset(int offset)
      Sets offset of buffer.
      Parameters:
      offset - the new offset
    • increaseBuffer

      public void increaseBuffer(int increase)
      Increases the buffer.
      Parameters:
      increase - the number of bytes
    • getByteArray

      public byte[] getByteArray()
      Gets internal byte buffer.
    • getByteArray

      public byte[] getByteArray(int position, int length)
      Gets internal byte buffer.
    • release

      public void release()
    • limit

      public int limit()
    • limit

      public ByteBuffer limit(int limit)
    • position

      public int position()
    • position

      public ByteBuffer position(int position)
    • put

      public ByteBuffer put(byte[] src)
    • put

      public ByteBuffer put(byte b)
    • get

      public byte get()
    • get

      public byte get(int index)
    • put

      public ByteBuffer put(int index, byte b)
    • put

      public ByteBuffer put(byte[] src, int offset, int length)
    • get

      public ByteBuffer get(byte[] dst)
    • get

      public ByteBuffer get(byte[] dst, int offset, int length)
    • putChar

      public ByteBuffer putChar(char value)
    • putChar

      public ByteBuffer putChar(int index, char value)
    • getChar

      public char getChar()
    • getChar

      public char getChar(int index)
    • putInt

      public ByteBuffer putInt(int value)
    • putInt

      public ByteBuffer putInt(int index, int value)
    • getInt

      public int getInt()
    • getInt

      public int getInt(int index)
    • putLong

      public ByteBuffer putLong(long value)
    • putLong

      public ByteBuffer putLong(int index, long value)
    • getLong

      public long getLong()
    • getLong

      public long getLong(int index)
    • putDouble

      public ByteBuffer putDouble(double value)
    • putDouble

      public ByteBuffer putDouble(int index, double value)
    • getDouble

      public double getDouble()
    • getDouble

      public double getDouble(int index)
    • putInAll

      public ByteBuffer putInAll(int start, int end, byte value)
    • remaining

      public int remaining()
    • flip

      public ByteBuffer flip()
    • demand

      public static ByteBuffer demand(int size)
    • release

      public static void release(ByteBuffer buffer)
    • getNioBuffer

      public ByteBuffer getNioBuffer()
    • resetBuffer

      public void resetBuffer()
      Resets the buffer.
    • getOffset

      public int getOffset()
      Gets buffer offset.
    • getLength

      public int getLength()
      Gets buffer length.
      Returns:
      int length
    • getBulk

      public byte[] getBulk()
    • isEmpty

      public boolean isEmpty()
    • wrapBuffer

      public static ByteBuffer wrapBuffer(byte[] buffer)
    • getSubArray

      public byte[] getSubArray(int start, int length)