public abstract class DataType
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static DataType |
BYTE |
static DataType |
CHAR |
static DataType |
DOUBLE |
static DataType |
EPOCH |
static DataType |
EPOCH16 |
static DataType |
FLOAT |
static DataType |
INT1 |
static DataType |
INT2 |
static DataType |
INT4 |
static DataType |
INT8 |
static DataType |
REAL4 |
static DataType |
REAL8 |
static DataType |
TIME_TT2000 |
static DataType |
UCHAR |
static DataType |
UINT1 |
static DataType |
UINT2 |
static DataType |
UINT4 |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
formatArrayValue(java.lang.Object array,
int arrayIndex)
Provides a string view of an item obtained from an array value
of this data type.
|
java.lang.String |
formatScalarValue(java.lang.Object value)
Provides a string view of a scalar value obtained for this data type.
|
java.lang.Class<?> |
getArrayElementClass()
Returns the element class of an array that this data type can
be read into.
|
int |
getArrayIndex(int itemIndex)
Returns the index into a value array which corresponds to the
item 'th element. |
int |
getByteCount()
Returns the number of bytes used in a CDF to store a single item
of this type.
|
static DataType |
getDataType(int dataType)
Returns the DataType object corresponding to a CDF data type code.
|
static DataType |
getDataType(int dataType,
CdfInfo cdfInfo)
Returns a DataType corresponding to a CDF data type code,
possibly customised for a particular CDF file.
|
java.lang.Object |
getDefaultPadValueArray()
Returns an array of array-class values containing a single item
with the default pad value for this type.
|
int |
getGroupSize()
Number of elements of type arrayElementClass that are read into
valueArray for a single item read.
|
java.lang.String |
getName()
Returns the name for this data type.
|
abstract java.lang.Object |
getScalar(java.lang.Object valueArray,
int arrayIndex)
Reads a single item from an array which has previously been
populated by
readValues . |
java.lang.Class<?> |
getScalarClass()
Returns the type of objects obtained by the
getScalar
method. |
boolean |
hasMultipleElementsPerItem()
True if this type may turn a variable number of elements from the
value array into a single read item.
|
abstract void |
readValues(Buf buf,
long offset,
int nelPerItem,
java.lang.Object valueArray,
int count)
Reads data of this data type from a buffer into an appropriately
typed value array.
|
java.lang.String |
toString() |
public static final DataType INT1
public static final DataType INT2
public static final DataType INT4
public static final DataType INT8
public static final DataType UINT1
public static final DataType UINT2
public static final DataType UINT4
public static final DataType REAL4
public static final DataType REAL8
public static final DataType CHAR
public static final DataType EPOCH16
public static final DataType BYTE
public static final DataType FLOAT
public static final DataType DOUBLE
public static final DataType EPOCH
public static final DataType TIME_TT2000
public static final DataType UCHAR
public java.lang.String getName()
public int getByteCount()
public java.lang.Class<?> getArrayElementClass()
public java.lang.Class<?> getScalarClass()
getScalar
method.public int getGroupSize()
public int getArrayIndex(int itemIndex)
item
'th element.itemIndex
* groupSize
public boolean hasMultipleElementsPerItem()
public java.lang.Object getDefaultPadValueArray()
public abstract void readValues(Buf buf, long offset, int nelPerItem, java.lang.Object valueArray, int count) throws java.io.IOException
buf
- data bufferoffset
- byte offset into buffer at which data startsnelPerItem
- number of elements per item;
usually 1, but may not be for stringsvalueArray
- array to receive result datacount
- number of items to readjava.io.IOException
public abstract java.lang.Object getScalar(java.lang.Object valueArray, int arrayIndex)
readValues
.
The class of the returned value is that returned by
getScalarClass()
.
The arrayIndex
argument is the index into the
array object, not necessarily the item index -
see the getArrayIndex
method.
valueArray
- array filled with data for this data typearrayIndex
- index into array at which the item to read is foundindex
in valueArray
public java.lang.String formatScalarValue(java.lang.Object value)
value
- value returned by getScalar
public java.lang.String formatArrayValue(java.lang.Object array, int arrayIndex)
The arrayIndex
argument is the index into the
array object, not necessarily the item index -
see the getArrayIndex
method.
array
- array value populated by readValues
arrayIndex
- index into arraypublic java.lang.String toString()
toString
in class java.lang.Object
public static DataType getDataType(int dataType, CdfInfo cdfInfo) throws CdfFormatException
Currently, this returns the same as getDataType(int)
,
except for TIME_TT2000 columns, in which case the last known leap
second may be taken into account.
dataType
- dataType field of AEDR or VDRcdfInfo
- specifics of CDF fileCdfFormatException
public static DataType getDataType(int dataType) throws CdfFormatException
dataType
- dataType field of AEDR or VDRCdfFormatException