Package ints
Class UnsignedByteArray
- java.lang.Object
-
- ints.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 abyte[]
array whose values have been translated by -128.Instances of
UnsignedByteArray
are immutable.
-
-
Constructor Summary
Constructors Constructor Description UnsignedByteArray(byte[] ba)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(byte[] ba, int from, int to)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(int[] ia)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(int[] ia, int valueSize)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(int[] ia, int from, int to)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(IntList il)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(IntList il, int valueSize)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(IntList il, int from, int to)
Constructs a newUnsignedByteArray
instance from the specified data.UnsignedByteArray(java.io.ByteArrayOutputStream baos)
Constructs a newUnsignedByteArray
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 thisIntArray
.java.lang.String
toString()
void
write(java.io.OutputStream os)
Writethis
byte array to the specified output stream.
-
-
-
Constructor Detail
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba)
Constructs a newUnsignedByteArray
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
- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba, int from, int to)
Constructs a newUnsignedByteArray
instance 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 > from
java.lang.NullPointerException
- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia)
Constructs a newUnsignedByteArray
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 indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il)
Constructs a newUnsignedByteArray
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 indexj
satisfying(j >= 0 && j < il.size())
java.lang.NullPointerException
- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int valueSize)
Constructs a newUnsignedByteArray
instance 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 > 256
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il, int valueSize)
Constructs a newUnsignedByteArray
instance 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 indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int from, int to)
Constructs a newUnsignedByteArray
instance 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 indexj
satisfying(j >= from && j < to)
java.lang.IndexOutOfBoundsException
- if(from < 0 || to > ia.length)
java.lang.NegativeArraySizeException
- ifto > from
java.lang.NullPointerException
- ifia == null
-
UnsignedByteArray
public UnsignedByteArray(IntList il, int from, int to)
Constructs a newUnsignedByteArray
instance 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 indexj
satisfying(j >= from && j < to)
java.lang.IndexOutOfBoundsException
- iffrom < 0 || to > il.length
java.lang.NegativeArraySizeException
- ifto > from
java.lang.NullPointerException
- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(java.io.ByteArrayOutputStream baos)
Constructs a newUnsignedByteArray
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
- ifbaos == null
-
-
Method Detail
-
size
public int size()
Description copied from interface:IntArray
Returns the number of elements in thisIntArray
.
-
get
public int get(int index)
Description copied from interface:IntArray
Returns the specified array element.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
write
public void write(java.io.OutputStream os) throws java.io.IOException
Writethis
byte array to the specified output stream.- Parameters:
os
- an output stream- Throws:
java.io.IOException
- if an I/O error occurs
-
-