Class ByteArray

java.lang.Object
com.itextpdf.barcodes.qrcode.ByteArray

final class ByteArray extends Object
This class implements an array of unsigned bytes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private static final int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new ByteArray instance with size 0.
    ByteArray(byte[] byteArray)
    Creates a new ByteArray instance based on an existing byte[].
    ByteArray(int size)
    Creates a new ByteArray instance of the specified size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendByte(int value)
    Append a byte to the end of the array.
    int
    at(int index)
    Access an unsigned byte at location index.
    boolean
     
    void
    reserve(int capacity)
    Increase the capacity of the array to "capacity" if the current capacity is smaller
    void
    set(byte[] source, int offset, int count)
    Copy count bytes from array source starting at offset.
    void
    set(int index, int value)
    Set the value at "index" to "value"
    int
     

    Methods inherited from class java.lang.Object

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

    • INITIAL_SIZE

      private static final int INITIAL_SIZE
      See Also:
    • bytes

      private byte[] bytes
    • size

      private int size
  • Constructor Details

    • ByteArray

      public ByteArray()
      Creates a new ByteArray instance with size 0.
    • ByteArray

      public ByteArray(int size)
      Creates a new ByteArray instance of the specified size.
      Parameters:
      size - size of the array
    • ByteArray

      public ByteArray(byte[] byteArray)
      Creates a new ByteArray instance based on an existing byte[].
      Parameters:
      byteArray - the byte[]
  • Method Details

    • at

      public int at(int index)
      Access an unsigned byte at location index.
      Parameters:
      index - The index in the array to access.
      Returns:
      The unsigned value of the byte as an int.
    • set

      public void set(int index, int value)
      Set the value at "index" to "value"
      Parameters:
      index - position in the byte-array
      value - new value
    • size

      public int size()
      Returns:
      size of the array
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if size is equal to 0, false otherwise
    • appendByte

      public void appendByte(int value)
      Append a byte to the end of the array. If the array is too small, it's capacity is doubled.
      Parameters:
      value - byte to append.
    • reserve

      public void reserve(int capacity)
      Increase the capacity of the array to "capacity" if the current capacity is smaller
      Parameters:
      capacity - the new capacity
    • set

      public void set(byte[] source, int offset, int count)
      Copy count bytes from array source starting at offset.
      Parameters:
      source - source of the copied bytes
      offset - offset to start at
      count - number of bytes to copy