Package uk.ac.bristol.star.cdf.record
Class Record
java.lang.Object
uk.ac.bristol.star.cdf.record.Record
- Direct Known Subclasses:
AttributeDescriptorRecord
,AttributeEntryDescriptorRecord
,CdfDescriptorRecord
,CompressedCdfRecord
,CompressedParametersRecord
,CompressedVariableValuesRecord
,GlobalDescriptorRecord
,SparsenessParametersRecord
,UnusedInternalRecord
,VariableDescriptorRecord
,VariableIndexRecord
,VariableValuesRecord
Abstract superclass for a CDF Record object.
A Record represents one of the sequence of typed records
of which a CDF file is composed.
- Since:
- 18 Jun 2013
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Record
(RecordPlan plan, String abbrev) Constructs a record with no known record type.protected
Record
(RecordPlan plan, String abbrev, int fixedType) Constructs a record with a known record type. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkEndRecord
(Pointer ptr) Checks that a pointer is positioned at the end of this record.getBuf()
Returns the buffer containing the record data.long
Returns the buffer offset of the first field in this record after the record size and type values.long
Returns the size of the record in bytes.int
Returns the type code identifying what kind of CDF record it is.Returns the abbreviated form of the record type for this record.static boolean
hasBit
(int flags, int ibit) Indicates whether a given bit of a flags mask is set.static int[]
readIntArray
(Buf buf, Pointer ptr, int count) Reads a moderately-sized array of 4-byte big-endian integers.static long[]
readOffsetArray
(Buf buf, Pointer ptr, int count) Reads a moderately-sized offset 8-byte big-endian integers.static String[]
Splits an ASCII string into 0x0A-terminated lines.protected void
warnFormat
(String msg) Called bycheck*
methods to issue a warning if the check has failed.
-
Constructor Details
-
Record
Constructs a record with no known record type.- Parameters:
plan
- basic record informationabbrev
- abreviated name for record type
-
Record
Constructs a record with a known record type.- Parameters:
plan
- basic record informationabbrev
- abreviated name for record typefixedType
- record type asserted for this record
-
-
Method Details
-
getRecordSize
public long getRecordSize()Returns the size of the record in bytes.- Returns:
- record size
-
getRecordType
public int getRecordType()Returns the type code identifying what kind of CDF record it is.- Returns:
- record type
-
getBuf
Returns the buffer containing the record data.- Returns:
- buffer
-
getRecordTypeAbbreviation
Returns the abbreviated form of the record type for this record.- Returns:
- record type abbreviation
-
getContentOffset
public long getContentOffset()Returns the buffer offset of the first field in this record after the record size and type values.- Returns:
- buffer offset for non-generic record content
-
checkEndRecord
Checks that a pointer is positioned at the end of this record. If not, a warning may be emitted. This performs an assertion-like function. This can be called by code which thinks it has read a whole record's content to check that it's got the counting right.- Parameters:
ptr
- pointer notionally positioned at end of record
-
warnFormat
Called bycheck*
methods to issue a warning if the check has failed.- Parameters:
msg
- message to output
-
readIntArray
Reads a moderately-sized array of 4-byte big-endian integers. Pointer position is moved on appropriately. Not intended for potentially very large arrays.- Parameters:
buf
- bufferptr
- pointercount
- number of values to read- Returns:
count
-element array of values- Throws:
IOException
-
readOffsetArray
Reads a moderately-sized offset 8-byte big-endian integers. Pointer position is moved on appropriately. Not intended for potentially very large arrays.- Parameters:
buf
- bufferptr
- pointercount
- number of values to read- Returns:
count
-element array of values- Throws:
IOException
-
toLines
Splits an ASCII string into 0x0A-terminated lines.- Parameters:
text
- string containing ASCII characters- Returns:
- array of lines split on linefeeds
-
hasBit
public static boolean hasBit(int flags, int ibit) Indicates whether a given bit of a flags mask is set.- Parameters:
flags
- flags maskibit
- bit index; 0 is the least significant
-