uk.ac.bristol.star.cdf.record
Class DataReader

java.lang.Object
  extended by 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
DataReader(DataType dataType, int nelPerItem, int nItem)
          Constructor.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 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 buffer
offset - byte offset into buf of data start
valueArray - object created by createValueArray 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