Package de.pco.common
Class AbstractUnsignedArray
java.lang.Object
de.pco.common.AbstractUnsignedArray
- Direct Known Subclasses:
UByteArray,UShortArray
public abstract class AbstractUnsignedArray extends Object
Abstract class that represents an array of values of an unsigned data type.
Due to the inabilities of Java, these are stored in the backing buffer as the
signed values of a particular Java data type and get converted to the array of
unsigned values when
getArray() is called.- Author:
- PCO
-
Field Summary
Fields Modifier and Type Field Description protected ByteBufferbuffer -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractUnsignedArray(int[] array)Constructor for creating the array from the real unsigned values.protectedAbstractUnsignedArray(Object signedSubtypeArray)This constructor from the array of bytes or shorts will be used after the native call to record the data will be performed in the C level of JNI. -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)abstract int[]getArray()Returns the factual array of unsigned values.abstract ObjectgetBackingArray()Returns the array as it is stored in the buffer as the array of a particular Java data type.InputStreamgetInputStream()Returns an InputStream on the backing buffer.inthashCode()abstract intlength()Returns the number of stored values, i.e. the length of both arrays returned bygetArray()andgetBackingArray().StringtoString()
-
Field Details
-
buffer
-
-
Constructor Details
-
AbstractUnsignedArray
This constructor from the array of bytes or shorts will be used after the native call to record the data will be performed in the C level of JNI.- Parameters:
signedSubtypeArray-
-
AbstractUnsignedArray
Constructor for creating the array from the real unsigned values. This would be used after manual computation with the image values to wrap the array again.- Parameters:
array-- Throws:
IllegalArgumentException
-
-
Method Details
-
getArray
public abstract int[] getArray()Returns the factual array of unsigned values. To be called when there is a need for displaying or manually counting with the real values. Converts from the backing byte array every time.- Returns:
-
getBackingArray
Returns the array as it is stored in the buffer as the array of a particular Java data type. To be used for reading to a BufferedImage in the ImageIO framework.- Returns:
-
getInputStream
Returns an InputStream on the backing buffer.- Returns:
-
length
public abstract int length()Returns the number of stored values, i.e. the length of both arrays returned bygetArray()andgetBackingArray().- Returns:
-
hashCode
public int hashCode() -
equals
-
toString
-