Class RecordFactory

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

public class RecordFactory extends Object
Turns bytes in a buffer into typed and populated CDF records.
Since:
18 Jun 2013
  • Constructor Details

    • RecordFactory

      public RecordFactory(int nameLeng)
      Constructor.
      Parameters:
      nameLeng - number of bytes in variable and attribute names; appears to be 64 for pre-v3 and 256 for v3
  • Method Details

    • createRecord

      public Record createRecord(Buf buf, long offset) throws IOException
      Creates a Record object from a given position in a buffer. The returned object will be an instance of one of the Record subclasses as appropriate for its type.
      Parameters:
      buf - byte buffer
      offset - start of record in buf
      Returns:
      record
      Throws:
      IOException
    • createRecord

      public <R extends Record> R createRecord(Buf buf, long offset, Class<R> clazz) throws IOException
      Creates a Record object with a known type from a given position in a buffer. This simply calls the untyped getRecord method, and attempts to cast the result, throwing a CdfFormatException if it has the wrong type.
      Parameters:
      buf - byte buffer
      offset - start of record in buf
      clazz - record class asserted for the result
      Returns:
      record
      Throws:
      CdfFormatException - if the record found there turns out not to be of type clazz
      IOException