Class DataReader

java.lang.Object
uk.ac.bristol.star.cdf.record.DataReader

public class DataReader extends Object
Reads items with a given data type from a buffer into an array.
Since:
20 Jun 2013
  • Constructor Details

    • DataReader

      public DataReader(DataType dataType, int nelPerItem, int nItem)
      Constructor.
      Parameters:
      dataType - data type
      nelPerItem - number of dataType elements per read item; usually 1 except for character data
      nItem - number of items of given data type in the array, for scalar records it will be 1
  • Method Details

    • createValueArray

      public 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, Object valueArray) throws IOException
      Reads a value from a data buffer into a workspace array.
      Parameters:
      buf - data buffer
      offset - byte offset into buf of data start
      valueArray - object created by createValueArray into which results will be read
      Throws:
      IOException
    • getRecordSize

      public int getRecordSize()
      Returns the size in bytes of one record as stored in the data buffer.
      Returns:
      record size in bytes