Package ints

Class UnsignedByteArray

  • All Implemented Interfaces:
    IntArray

    public final class UnsignedByteArray
    extends java.lang.Object
    implements IntArray

    Class UnsignedByteIndexArray represents an immutable array of integer values between 0 and 255 inclusive that is stored as a byte[] array whose values have been translated by -128.

    Instances of UnsignedByteArray are immutable.

    • Constructor Summary

      Constructors 
      Constructor Description
      UnsignedByteArray​(byte[] ba)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(byte[] ba, int from, int to)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(int[] ia)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(int[] ia, int valueSize)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(int[] ia, int from, int to)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(IntList il)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(IntList il, int valueSize)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(IntList il, int from, int to)
      Constructs a new UnsignedByteArray instance from the specified data.
      UnsignedByteArray​(java.io.ByteArrayOutputStream baos)
      Constructs a new UnsignedByteArray instance from the specified data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int get​(int index)
      Returns the specified array element.
      int size()
      Returns the number of elements in this IntArray.
      java.lang.String toString()  
      void write​(java.io.OutputStream os)
      Write this byte array to the specified output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • UnsignedByteArray

        public UnsignedByteArray​(byte[] ba)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        ba - an array of bytes which are interpreted as unsigned byte values between 0 and 255
        Throws:
        java.lang.NullPointerException - if ba == null
      • UnsignedByteArray

        public UnsignedByteArray​(byte[] ba,
                                 int from,
                                 int to)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        ba - an array of bytes which are interpreted as unsigned byte values between 0 and 255
        from - the first element to be included (inclusive)
        to - the last element to be included (exclusive)
        Throws:
        java.lang.IndexOutOfBoundsException - if (from < 0 || to > ia.length)
        java.lang.NegativeArraySizeException - if to > from
        java.lang.NullPointerException - if ba == null
      • UnsignedByteArray

        public UnsignedByteArray​(int[] ia)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        ia - an array of positive integer values whose lower order byte will be stored
        Throws:
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > 255) for any index j satisfying (j >= 0 && j < ia.length)
        java.lang.NullPointerException - if ia == null
      • UnsignedByteArray

        public UnsignedByteArray​(IntList il)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        il - an list of integer values between 0 and 255 inclusive
        Throws:
        java.lang.IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > 255) for any index j satisfying (j >= 0 && j < il.size())
        java.lang.NullPointerException - if il == null
      • UnsignedByteArray

        public UnsignedByteArray​(int[] ia,
                                 int valueSize)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        ia - an array of nonnegative integer values
        valueSize - the exclusive end of the range of non-negative array values
        Throws:
        java.lang.IllegalArgumentException - if valueSize < 1 || valueSize > 256
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
        java.lang.NullPointerException - if ia == null
      • UnsignedByteArray

        public UnsignedByteArray​(IntList il,
                                 int valueSize)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        il - an list of nonnegative integers
        valueSize - the exclusive end of the range of non-negative array values
        Throws:
        java.lang.IllegalArgumentException - if (valueSize < 1) || (valueSize > 256)
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
        java.lang.NullPointerException - if il == null
      • UnsignedByteArray

        public UnsignedByteArray​(int[] ia,
                                 int from,
                                 int to)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        ia - an array of integer values between 0 and 255 inclusive
        from - the first element to be included (inclusive)
        to - the last element to be included (exclusive)
        Throws:
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > 255) for any index j satisfying (j >= from && j < to)
        java.lang.IndexOutOfBoundsException - if (from < 0 || to > ia.length)
        java.lang.NegativeArraySizeException - if to > from
        java.lang.NullPointerException - if ia == null
      • UnsignedByteArray

        public UnsignedByteArray​(IntList il,
                                 int from,
                                 int to)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        il - an list of integer values between 0 and 255 inclusive
        from - the first element to be included (inclusive)
        to - the last element to be included (exclusive)
        Throws:
        java.lang.IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > 255) for any index j satisfying (j >= from && j < to)
        java.lang.IndexOutOfBoundsException - if from < 0 || to > il.length
        java.lang.NegativeArraySizeException - if to > from
        java.lang.NullPointerException - if il == null
      • UnsignedByteArray

        public UnsignedByteArray​(java.io.ByteArrayOutputStream baos)
        Constructs a new UnsignedByteArray instance from the specified data.
        Parameters:
        baos - a byte array output stream whose elements are interpreted as unsigned byte values between 0 and 255
        Throws:
        java.lang.NullPointerException - if baos == null
    • Method Detail

      • size

        public int size()
        Description copied from interface: IntArray
        Returns the number of elements in this IntArray.
        Specified by:
        size in interface IntArray
        Returns:
        the number of elements in this IntArray
      • get

        public int get​(int index)
        Description copied from interface: IntArray
        Returns the specified array element.
        Specified by:
        get in interface IntArray
        Parameters:
        index - an array index
        Returns:
        the specified array element
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • write

        public void write​(java.io.OutputStream os)
                   throws java.io.IOException
        Write this byte array to the specified output stream.
        Parameters:
        os - an output stream
        Throws:
        java.io.IOException - if an I/O error occurs