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

public abstract class Record extends Object
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

    Constructors
    Modifier
    Constructor
    Description
    protected
    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 Type
    Method
    Description
    protected void
    Checks that a pointer is positioned at the end of this record.
    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
    Called by check* methods to issue a warning if the check has failed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Record

      protected Record(RecordPlan plan, String abbrev)
      Constructs a record with no known record type.
      Parameters:
      plan - basic record information
      abbrev - abreviated name for record type
    • Record

      protected Record(RecordPlan plan, String abbrev, int fixedType)
      Constructs a record with a known record type.
      Parameters:
      plan - basic record information
      abbrev - abreviated name for record type
      fixedType - 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

      public Buf getBuf()
      Returns the buffer containing the record data.
      Returns:
      buffer
    • getRecordTypeAbbreviation

      public String 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

      protected void checkEndRecord(Pointer ptr)
      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

      protected void warnFormat(String msg)
      Called by check* methods to issue a warning if the check has failed.
      Parameters:
      msg - message to output
    • readIntArray

      public static int[] readIntArray(Buf buf, Pointer ptr, int count) throws IOException
      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 - buffer
      ptr - pointer
      count - number of values to read
      Returns:
      count-element array of values
      Throws:
      IOException
    • readOffsetArray

      public static long[] readOffsetArray(Buf buf, Pointer ptr, int count) throws IOException
      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 - buffer
      ptr - pointer
      count - number of values to read
      Returns:
      count-element array of values
      Throws:
      IOException
    • toLines

      public static String[] toLines(String text)
      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 mask
      ibit - bit index; 0 is the least significant