Class ExpansibleByteBuffer

java.lang.Object
org.apache.directory.api.util.ExpansibleByteBuffer

public class ExpansibleByteBuffer extends Object
A dynamically growing byte[].
Author:
Apache Directory Project
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a default ExpansibleByteBuffer capable of holding 10 bytes
    ExpansibleByteBuffer(int initialSize)
    Creates a ExpansibleByteBuffer which has an initialze size
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    append(byte b)
    Appends a byte to this buffer.
    final void
    append(byte[] bytes)
    Appends the bytes to this buffer.
    final void
    append(int val)
    Appends an int to this buffer.
    final byte[]
    Get's the bytes, the backing store for this buffer.
    final int
    Capacity of the buffer
    final void
    Reset the Buffer position to 0.
    final byte[]
    Get's a copy of the bytes used.
    final byte
    get(int i)
    Returns the byte at a given position.
    final int
    Position of the last byte in the buffer
    final void
    position(int pos)
    Set the position to a specific value

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExpansibleByteBuffer

      public ExpansibleByteBuffer()
      Create a default ExpansibleByteBuffer capable of holding 10 bytes
    • ExpansibleByteBuffer

      public ExpansibleByteBuffer(int initialSize)
      Creates a ExpansibleByteBuffer which has an initialze size
      Parameters:
      initialSize - The initial buffer size
  • Method Details

    • clear

      public final void clear()
      Reset the Buffer position to 0. Every new added byte will be put on position 0. Note that whatever this buffer contained before a call to the clear() method will not be removed.
    • position

      public final int position()
      Position of the last byte in the buffer
      Returns:
      The position of the last byte in the buffer
    • position

      public final void position(int pos)
      Set the position to a specific value
      Parameters:
      pos - the new position
    • capacity

      public final int capacity()
      Capacity of the buffer
      Returns:
      The number of bytes that can be added into this buffer
    • get

      public final byte get(int i)
      Returns the byte at a given position. Note that no control is done on the position validity.
      Parameters:
      i - The position
      Returns:
      The byte at the given position in the buffer
    • buffer

      public final byte[] buffer()
      Get's the bytes, the backing store for this buffer. Note that you need to use the position index to determine where to stop reading from this buffer.
      Returns:
      The interned Byte[]
    • copyOfUsedBytes

      public final byte[] copyOfUsedBytes()
      Get's a copy of the bytes used.
      Returns:
      A copy of the interned Byte[]
    • append

      public final void append(byte[] bytes)
      Appends the bytes to this buffer.
      Parameters:
      bytes - The byte[] to append to the buffer
    • append

      public final void append(byte b)
      Appends a byte to this buffer.
      Parameters:
      b - The byte to append to the buffer
    • append

      public final void append(int val)
      Appends an int to this buffer. WARNING: the int is truncated to a byte value.
      Parameters:
      val - The integer to append to the buffer