Package uk.ac.bristol.star.cdf.record
Class DataReader
- java.lang.Object
-
- uk.ac.bristol.star.cdf.record.DataReader
-
public class DataReader extends java.lang.Object
Reads items with a given data type from a buffer into an array.- Since:
- 20 Jun 2013
-
-
Constructor Summary
Constructors Constructor Description DataReader(DataType dataType, int nelPerItem, int nItem)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
createValueArray()
Creates a workspace array which can contain a value read for one record.int
getRecordSize()
Returns the size in bytes of one record as stored in the data buffer.void
readValue(Buf buf, long offset, java.lang.Object valueArray)
Reads a value from a data buffer into a workspace array.
-
-
-
Constructor Detail
-
DataReader
public DataReader(DataType dataType, int nelPerItem, int nItem)
Constructor.- Parameters:
dataType
- data typenelPerItem
- number of dataType elements per read item; usually 1 except for character datanItem
- number of items of given data type in the array, for scalar records it will be 1
-
-
Method Detail
-
createValueArray
public java.lang.Object createValueArray()
Creates a workspace array which can contain a value read for one record. The return value will be an array of a primitive type or String.- Returns:
- workspace array for this reader
-
readValue
public void readValue(Buf buf, long offset, java.lang.Object valueArray) throws java.io.IOException
Reads a value from a data buffer into a workspace array.- Parameters:
buf
- data bufferoffset
- byte offset into buf of data startvalueArray
- object created bycreateValueArray
into which results will be read- Throws:
java.io.IOException
-
getRecordSize
public int getRecordSize()
Returns the size in bytes of one record as stored in the data buffer.- Returns:
- record size in bytes
-
-