Package uk.ac.bristol.star.cdf.record
Class RecordFactory
- java.lang.Object
-
- uk.ac.bristol.star.cdf.record.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>
RcreateRecord(Buf buf, long offset, java.lang.Class<R> clazz)
Creates a Record object with a known type from a given position in a buffer.
-
-
-
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 bufferoffset
- 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 untypedgetRecord
method, and attempts to cast the result, throwing a CdfFormatException if it has the wrong type.- Parameters:
buf
- byte bufferoffset
- start of record in bufclazz
- record class asserted for the result- Returns:
- record
- Throws:
CdfFormatException
- if the record found there turns out not to be of typeclazz
java.io.IOException
-
-