public class Type
extends java.lang.Object
NDArray
.
This class exemplifies the typesafe enum pattern -- the only possible instances are supplied as static final fields of the class, and these instances are immutable.
Modifier and Type | Field and Description |
---|---|
static Type |
BYTE
Object representing primitive data of
byte type. |
static Type |
DOUBLE
Object representing primitive data of
double type. |
static Type |
FLOAT
Object representing primitive data of
float type. |
static Type |
INT
Object representing primitive data of
int type. |
static Type |
SHORT
Object representing primitive data of
short type. |
Modifier and Type | Method and Description |
---|---|
static java.util.List |
allTypes()
Returns a list of all the known Types.
|
void |
checkArray(java.lang.Object array,
int minsize)
Checks that a given Object is in fact an array of the primitive
type corresponding to this Type, and contains at least a given
number of elements; throws an exception if not.
|
BadHandler |
defaultBadHandler()
Returns a default bad value handler for this type.
|
java.lang.Number |
defaultBadValue()
Returns the default bad value used for this type.
|
int |
getNumBytes()
Returns the number of bytes occupied by this primitive type.
|
static Type |
getType(java.lang.Class cls)
Returns the Type object corresponding to a given java class.
|
boolean |
isFloating()
Indicates whether this type represents floating point values.
|
java.lang.Class |
javaClass()
Returns the java primitive class associated with this type.
|
double |
maximumValue()
Returns the highest value which can be represented by this type.
|
double |
minimumValue()
Returns the lowest (= most negative) value which
can be represented by this type.
|
java.lang.Object |
newArray(int size)
Constructs a new primitive array of a requested size and the
appropriate type for this object.
|
java.lang.String |
toString() |
public static final Type BYTE
byte
type.public static final Type SHORT
short
type.public static final Type INT
int
type.public static final Type FLOAT
float
type.public static final Type DOUBLE
double
type.public java.lang.String toString()
toString
in class java.lang.Object
public int getNumBytes()
public java.lang.Class javaClass()
public java.lang.Number defaultBadValue()
public BadHandler defaultBadHandler()
defaultBadValue
method.public boolean isFloating()
public double minimumValue()
public double maximumValue()
public java.lang.Object newArray(int size)
Array.newInstance(java.lang.Class<?>, int)
.size
- the number of elements requiredpublic void checkArray(java.lang.Object array, int minsize)
array
- an Object purporting to be a java array of
primitives of the right primitive type for this
Type and of at least minsize elementsminsize
- the minimum satisfactory size of arrayjava.lang.IllegalArgumentException
- if array is not an array or
has fewer than minSize elementspublic static java.util.List allTypes()
public static Type getType(java.lang.Class cls)
cls
- a (presumably numeric primitive) class.
May be nullCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.