Class CdfReader
- java.lang.Object
-
- uk.ac.bristol.star.cdf.CdfReader
-
public class CdfReader extends java.lang.Object
Examines a CDF file and provides methods to access its records.Constructing an instance of this class reads enough of a file to identify it as a CDF and work out how to access its records. Most of the actual contents are only read from the data buffer as required. Although only the magic numbers and CDR are read during construction, in the case of a file-compressed CDF the whole thing is uncompressed, so it could still be an expensive operation.
For low-level access to the CDF internal records, use the
getCdr()
method to get the CdfDescriptorRecord and use that in conjunction with knowledge of the internal format of CDF files as a starting point to chase pointers around the file constructing other records. When you have a pointer to another record, you can use the record factory got fromgetRecordFactory()
to turn it into a typed Record object.- Since:
- 19 Jun 2013
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Buf
getBuf()
Returns the buffer containing the uncompressed record stream for this reader's CDF file.CdfDescriptorRecord
getCdr()
Returns the CDF Descriptor Record object for this reader's CDF.RecordFactory
getRecordFactory()
Returns a RecordFactory that can be applied to this reader's Buf to construct CDF Record objects.static boolean
isMagic(byte[] intro)
Examines a byte array to see if it looks like the start of a CDF file.
-
-
-
Constructor Detail
-
CdfReader
public CdfReader(Buf buf) throws java.io.IOException
Constructs a CdfReader from a buffer containing its byte data.- Parameters:
buf
- buffer containing CDF file- Throws:
java.io.IOException
-
CdfReader
public CdfReader(java.io.File file) throws java.io.IOException
Constructs a CdfReader from a readable file containing its byte data.- Parameters:
file
- CDF file- Throws:
java.io.IOException
-
-
Method Detail
-
getBuf
public Buf getBuf()
Returns the buffer containing the uncompressed record stream for this reader's CDF file. This will be the buffer originally submitted at construction time only if the CDF does not use whole-file compression.- Returns:
- buffer containing CDF records
-
getRecordFactory
public RecordFactory getRecordFactory()
Returns a RecordFactory that can be applied to this reader's Buf to construct CDF Record objects.- Returns:
- record factory
-
getCdr
public CdfDescriptorRecord getCdr()
Returns the CDF Descriptor Record object for this reader's CDF.- Returns:
- CDF Descriptor Record
-
isMagic
public static boolean isMagic(byte[] intro)
Examines a byte array to see if it looks like the start of a CDF file.- Parameters:
intro
- byte array, at least 8 bytes if available- Returns:
- true iff the first 8 bytes of
intro
are a CDF magic number
-
-