Class ByteArray

java.lang.Object
com.neovisionaries.ws.client.ByteArray

class ByteArray extends Object
Expandable byte array with byte-basis and bit-basis operations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
     
    private ByteBuffer
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteArray(byte[] data)
    Constructor with initial data.
    ByteArray(int capacity)
    Constructor with initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    clearBit(int bitIndex)
     
    private void
    expandBuffer(int newBufferSize)
    Expand the size of the internal buffer.
    byte
    get(int index)
    Get a byte at the index.
    boolean
    getBit(int bitIndex)
     
    int
    getBits(int bitIndex, int nBits)
     
    int
    getHuffmanBits(int bitIndex, int nBits)
     
    int
    The length of the data.
    void
    put(byte[] source)
    Add data at the current position.
    void
    put(byte[] source, int index, int length)
    Add data at the current position.
    void
    put(int data)
    Add a byte at the current position.
    void
    put(ByteArray source, int index, int length)
    Add data at the current position.
    boolean
    readBit(int[] bitIndex)
     
    int
    readBits(int[] bitIndex, int nBits)
     
    void
    setBit(int bitIndex, boolean bit)
     
    void
    shrink(int size)
     
    byte[]
    Convert to a byte array (byte[]).
    byte[]
    toBytes(int beginIndex)
     
    byte[]
    toBytes(int beginIndex, int endIndex)
     

    Methods inherited from class java.lang.Object

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

    • ADDITIONAL_BUFFER_SIZE

      private static final int ADDITIONAL_BUFFER_SIZE
      See Also:
    • mBuffer

      private ByteBuffer mBuffer
    • mLength

      private int mLength
  • Constructor Details

    • ByteArray

      public ByteArray(int capacity)
      Constructor with initial capacity.
      Parameters:
      capacity - Initial capacity for the internal buffer.
    • ByteArray

      public ByteArray(byte[] data)
      Constructor with initial data. The length of the data is used as the initial capacity of the internal buffer.
      Parameters:
      data - Initial data.
  • Method Details

    • length

      public int length()
      The length of the data.
    • get

      public byte get(int index) throws IndexOutOfBoundsException
      Get a byte at the index.
      Throws:
      IndexOutOfBoundsException
    • expandBuffer

      private void expandBuffer(int newBufferSize)
      Expand the size of the internal buffer.
    • put

      public void put(int data)
      Add a byte at the current position.
    • put

      public void put(byte[] source)
      Add data at the current position.
      Parameters:
      source - Source data.
    • put

      public void put(byte[] source, int index, int length)
      Add data at the current position.
      Parameters:
      source - Source data.
      index - The index in the source data. Data from the index is copied.
      length - The length of data to copy.
    • put

      public void put(ByteArray source, int index, int length)
      Add data at the current position.
      Parameters:
      source - Source data.
      index - The index in the source data. Data from the index is copied.
      length - The length of data to copy.
    • toBytes

      public byte[] toBytes()
      Convert to a byte array (byte[]).
    • toBytes

      public byte[] toBytes(int beginIndex)
    • toBytes

      public byte[] toBytes(int beginIndex, int endIndex)
    • clear

      public void clear()
    • shrink

      public void shrink(int size)
    • getBit

      public boolean getBit(int bitIndex)
    • getBits

      public int getBits(int bitIndex, int nBits)
    • getHuffmanBits

      public int getHuffmanBits(int bitIndex, int nBits)
    • readBit

      public boolean readBit(int[] bitIndex)
    • readBits

      public int readBits(int[] bitIndex, int nBits)
    • setBit

      public void setBit(int bitIndex, boolean bit)
    • clearBit

      public void clearBit(int bitIndex)