Class CdfReader
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 from getRecordFactory()
to turn
it into a typed Record object.
- Since:
- 19 Jun 2013
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBuf()
Returns the buffer containing the uncompressed record stream for this reader's CDF file.getCdr()
Returns the CDF Descriptor Record object for this reader's CDF.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 Details
-
CdfReader
Constructs a CdfReader from a buffer containing its byte data.- Parameters:
buf
- buffer containing CDF file- Throws:
IOException
-
CdfReader
Constructs a CdfReader from a readable file containing its byte data.- Parameters:
file
- CDF file- Throws:
IOException
-
-
Method Details
-
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
Returns a RecordFactory that can be applied to this reader's Buf to construct CDF Record objects.- Returns:
- record factory
-
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
-