Package uk.ac.bristol.star.cdf.record
Class RecordFactory
java.lang.Object
uk.ac.bristol.star.cdf.record.RecordFactory
Turns bytes in a buffer into typed and populated CDF records.
- Since:
- 18 Jun 2013
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateRecord
(Buf buf, long offset) Creates a Record object from a given position in a buffer.<R extends Record>
RcreateRecord
(Buf buf, long offset, Class<R> clazz) Creates a Record object with a known type from a given position in a buffer.
-
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
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:
IOException
-
createRecord
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
IOException
-