| Modifier and Type | Class and Description |
|---|---|
static class |
DataType.Signedness
A property of
integral data types that determines whether they can represent both
positive and negative numbers (signed), or only non-negative numbers (unsigned). |
| Enum Constant and Description |
|---|
BOOLEAN |
BYTE |
CHAR |
DOUBLE |
ENUM1 |
ENUM2 |
ENUM4 |
FLOAT |
INT |
LONG |
OBJECT |
OPAQUE |
SEQUENCE |
SHORT |
STRING |
STRUCTURE |
UBYTE |
UINT |
ULONG |
USHORT |
| Modifier and Type | Method and Description |
|---|---|
static DataType |
enumTypeize(DataType dt) |
java.lang.Class |
getPrimitiveClassType()
The primitive class type: char, byte, float, double, short, int, long, boolean, String, StructureData,
StructureDataIterator, ByteBuffer.
|
DataType.Signedness |
getSignedness()
Returns the
signedness of this data type. |
int |
getSize()
Size in bytes of one element of this data type.
|
static DataType |
getType(Array arr) |
static DataType |
getType(java.lang.Class c,
boolean isUnsigned)
Find the DataType that matches this class.
|
static DataType |
getType(java.lang.String name)
Find the DataType that matches this name.
|
boolean |
isEnum()
Is this an enumeration types?
|
boolean |
isEnumCompatible(DataType inferred) |
boolean |
isFloatingPoint()
Is Float or Double
|
boolean |
isIntegral()
Is Byte, Int, Short, or Long
|
boolean |
isNumeric()
Is Byte, Float, Double, Int, Short, or Long
|
boolean |
isString()
Is String or Char
|
boolean |
isUnsigned()
Returns
true if the data type is unsigned. |
java.lang.String |
toString()
The DataType name, eg "byte", "float", "String".
|
static short |
unsignedByteToShort(byte b)
Widen an unsigned byte to a short.
|
static long |
unsignedIntToLong(int i)
Widen an unsigned int to a long.
|
static java.math.BigInteger |
unsignedLongToBigInt(long l)
Widen an unsigned long to a
BigInteger. |
static java.lang.String |
unsignedLongToString(long li)
convert an unsigned long to a String
|
static int |
unsignedShortToInt(short s)
Widen an unsigned short to an int.
|
static DataType |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static DataType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
static java.lang.Number |
widenNumber(java.lang.Number number)
Return a number that is equivalent to the specified value, but represented by the next larger data type.
|
DataType |
withSignedness(DataType.Signedness signedness)
Returns a DataType that is related to
this, but with the specified signedness. |
public static final DataType BOOLEAN
public static final DataType BYTE
public static final DataType CHAR
public static final DataType SHORT
public static final DataType INT
public static final DataType LONG
public static final DataType FLOAT
public static final DataType DOUBLE
public static final DataType SEQUENCE
public static final DataType STRING
public static final DataType STRUCTURE
public static final DataType ENUM1
public static final DataType ENUM2
public static final DataType ENUM4
public static final DataType OPAQUE
public static final DataType OBJECT
public static final DataType UBYTE
public static final DataType USHORT
public static final DataType UINT
public static final DataType ULONG
public static DataType[] values()
for (DataType c : DataType.values()) System.out.println(c);
public static DataType valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String toString()
toString in class java.lang.Enum<DataType>public int getSize()
public java.lang.Class getPrimitiveClassType()
public DataType.Signedness getSignedness()
signedness of this data type.
For non-integral data types, it is guaranteed to be DataType.Signedness.SIGNED.public boolean isUnsigned()
true if the data type is unsigned.
For non-integral data types, it is guaranteed to be false.true if the data type is unsigned.public boolean isString()
public boolean isNumeric()
public boolean isIntegral()
public boolean isFloatingPoint()
public boolean isEnum()
public DataType withSignedness(DataType.Signedness signedness)
this, but with the specified signedness.
This method is only meaningful for integral data types; if it is called on a non-integral
type, then this is simply returned. Examples:
assert DataType.INT.withSignedness(DataType.Signedness.UNSIGNED) == DataType.UINT; // INT to UINT assert DataType.ULONG.withSignedness(DataType.Signedness.SIGNED) == DataType.LONG; // ULONG to LONG assert DataType.SHORT.withSignedness(DataType.Signedness.SIGNED) == DataType.SHORT; // this: Same signs assert DataType.STRING.withSignedness(DataType.Signedness.UNSIGNED) == DataType.STRING; // this: Non-integral
signedness - the desired signedness of the returned DataType.this, but with the specified signedness.public boolean isEnumCompatible(DataType inferred)
public static DataType getType(java.lang.String name)
name - find DataType with this name.public static DataType getType(java.lang.Class c, boolean isUnsigned)
c - primitive or object class, eg float.class or Float.classpublic static java.lang.String unsignedLongToString(long li)
li - unsigned intpublic static java.lang.Number widenNumber(java.lang.Number number)
BigInteger.number - a number.public static java.math.BigInteger unsignedLongToBigInt(long l)
BigInteger.l - an unsigned longBigInteger value.public static long unsignedIntToLong(int i)
i - an unsigned int.public static int unsignedShortToInt(short s)
s - an unsigned short.public static short unsignedByteToShort(byte b)
b - an unsigned byte.