Class RecordFactory


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

      Constructors 
      Constructor Description
      RecordFactory​(int nameLeng)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Record createRecord​(Buf buf, long offset)
      Creates a Record object from a given position in a buffer.
      <R extends Record>
      R
      createRecord​(Buf buf, long offset, java.lang.Class<R> clazz)
      Creates a Record object with a known type from a given position in a buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 Detail

      • createRecord

        public Record createRecord​(Buf buf,
                                   long offset)
                            throws java.io.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:
        java.io.IOException
      • createRecord

        public <R extends Record> R createRecord​(Buf buf,
                                                 long offset,
                                                 java.lang.Class<R> clazz)
                                          throws java.io.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
        java.io.IOException