Package uk.ac.bristol.star.cdf
Class DataType
java.lang.Object
uk.ac.bristol.star.cdf.DataType
Enumerates the data types supported by the CDF format.
- Since:
- 20 Jun 2013
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
-
Method Summary
Modifier and TypeMethodDescriptionformatArrayValue
(Object array, int arrayIndex) Provides a string view of an item obtained from an array value of this data type.formatScalarValue
(Object value) Provides a string view of a scalar value obtained for this data type.Class
<?> 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 theitem
'th element.int
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.Returns an array of array-class values containing a single item with the default pad value for this type.int
Number of elements of type arrayElementClass that are read into valueArray for a single item read.getName()
Returns the name for this data type.abstract Object
Reads a single item from an array which has previously been populated byreadValues
.Class
<?> Returns the type of objects obtained by thegetScalar
method.boolean
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, Object valueArray, int count) Reads data of this data type from a buffer into an appropriately typed value array.toString()
-
Field Details
-
INT1
-
INT2
-
INT4
-
INT8
-
UINT1
-
UINT2
-
UINT4
-
REAL4
-
REAL8
-
CHAR
-
EPOCH16
-
BYTE
-
FLOAT
-
DOUBLE
-
EPOCH
-
TIME_TT2000
-
UCHAR
-
-
Method Details
-
getName
Returns the name for this data type.- Returns:
- data type name
-
getByteCount
public int getByteCount()Returns the number of bytes used in a CDF to store a single item of this type.- Returns:
- size in bytes
-
getArrayElementClass
Returns the element class of an array that this data type can be read into. In most cases this is a primitive type or String.- Returns:
- array raw value element class
-
getScalarClass
Returns the type of objects obtained by thegetScalar
method.- Returns:
- scalar type associated with this data type
-
getGroupSize
public int getGroupSize()Number of elements of type arrayElementClass that are read into valueArray for a single item read. This is usually 1, but not, for instance, for EPOCH16.- Returns:
- number of array elements per item
-
getArrayIndex
public int getArrayIndex(int itemIndex) Returns the index into a value array which corresponds to theitem
'th element.- Returns:
itemIndex
*groupSize
-
hasMultipleElementsPerItem
public boolean hasMultipleElementsPerItem()True if this type may turn a variable number of elements from the value array into a single read item. This is usually false, but true for character types, which turn into strings.- Returns:
- true iff type may have multiple elements per read item
-
getDefaultPadValueArray
Returns an array of array-class values containing a single item with the default pad value for this type.- Returns:
- default raw pad value array
- See Also:
-
readValues
public abstract void readValues(Buf buf, long offset, int nelPerItem, Object valueArray, int count) throws IOException Reads data of this data type from a buffer into an appropriately typed value array.- Parameters:
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 read- Throws:
IOException
-
getScalar
Reads a single item from an array which has previously been populated byreadValues
. The class of the returned value is that returned bygetScalarClass()
.The
arrayIndex
argument is the index into the array object, not necessarily the item index - see thegetArrayIndex
method.- Parameters:
valueArray
- array filled with data for this data typearrayIndex
- index into array at which the item to read is found- Returns:
- scalar representation of object at position
index
invalueArray
-
formatScalarValue
Provides a string view of a scalar value obtained for this data type.- Parameters:
value
- value returned bygetScalar
- Returns:
- string representation
-
formatArrayValue
Provides a string view of an item obtained from an array value of this data type.The
arrayIndex
argument is the index into the array object, not necessarily the item index - see thegetArrayIndex
method.- Parameters:
array
- array value populated byreadValues
arrayIndex
- index into array- Returns:
- string representation
-
toString
-
getDataType
Returns a DataType corresponding to a CDF data type code, possibly customised for a particular CDF file.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.- Parameters:
dataType
- dataType field of AEDR or VDRcdfInfo
- specifics of CDF file- Returns:
- data type object
- Throws:
CdfFormatException
-
getDataType
Returns the DataType object corresponding to a CDF data type code.- Parameters:
dataType
- dataType field of AEDR or VDR- Returns:
- data type object
- Throws:
CdfFormatException
-