Package ints
Class UnsignedByteArray
- java.lang.Object
-
- ints.UnsignedByteArray
-
- All Implemented Interfaces:
IntArray
public final class UnsignedByteArray extends java.lang.Object implements IntArray
Class
UnsignedByteIndexArrayrepresents an immutable array of integer values between 0 and 255 inclusive that is stored as abyte[]array whose values have been translated by -128.Instances of
UnsignedByteArrayare immutable.
-
-
Constructor Summary
Constructors Constructor Description UnsignedByteArray(byte[] ba)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(byte[] ba, int from, int to)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia, int valueSize)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia, int from, int to)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(IntList il)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(IntList il, int valueSize)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(IntList il, int from, int to)Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(java.io.ByteArrayOutputStream baos)Constructs a newUnsignedByteArrayinstance from the specified data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intget(int index)Returns the specified array element.intsize()Returns the number of elements in thisIntArray.java.lang.StringtoString()voidwrite(java.io.OutputStream os)Writethisbyte array to the specified output stream.
-
-
-
Constructor Detail
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba)
Constructs a newUnsignedByteArrayinstance 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- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba, int from, int to)Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ba- an array of bytes which are interpreted as unsigned byte values between 0 and 255from- 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- ifto > fromjava.lang.NullPointerException- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia)
Constructs a newUnsignedByteArrayinstance 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 indexjsatisfying(j >= 0 && j < ia.length)java.lang.NullPointerException- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il)
Constructs a newUnsignedByteArrayinstance 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 indexjsatisfying(j >= 0 && j < il.size())java.lang.NullPointerException- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int valueSize)Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ia- an array of nonnegative integer valuesvalueSize- the exclusive end of the range of non-negative array values- Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1 || valueSize > 256java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)java.lang.NullPointerException- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il, int valueSize)
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
il- an list of nonnegative integersvalueSize- 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 indexjsatisfying(j >= 0 && j < ia.length)java.lang.NullPointerException- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int from, int to)Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ia- an array of integer values between 0 and 255 inclusivefrom- 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 indexjsatisfying(j >= from && j < to)java.lang.IndexOutOfBoundsException- if(from < 0 || to > ia.length)java.lang.NegativeArraySizeException- ifto > fromjava.lang.NullPointerException- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il, int from, int to)
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
il- an list of integer values between 0 and 255 inclusivefrom- 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 indexjsatisfying(j >= from && j < to)java.lang.IndexOutOfBoundsException- iffrom < 0 || to > il.lengthjava.lang.NegativeArraySizeException- ifto > fromjava.lang.NullPointerException- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(java.io.ByteArrayOutputStream baos)
Constructs a newUnsignedByteArrayinstance 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- ifbaos == null
-
-
Method Detail
-
size
public int size()
Description copied from interface:IntArrayReturns the number of elements in thisIntArray.
-
get
public int get(int index)
Description copied from interface:IntArrayReturns the specified array element.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
write
public void write(java.io.OutputStream os) throws java.io.IOExceptionWritethisbyte array to the specified output stream.- Parameters:
os- an output stream- Throws:
java.io.IOException- if an I/O error occurs
-
-