Package ghidra.app.util.bin.format.omf

# Class OmfUtils

java.lang.Object
ghidra.app.util.bin.format.omf.OmfUtils

public class OmfUtils extends Object
Utility class for OMF-based file formats

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CATEGORY_PATH`
  Data type category

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OmfUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> Stream<T>`
  `filterRecords(List<OmfRecord> records, Class<T> classType)`
  Returns a `Stream` of `records` that match the given class type
  `static final String`
  `getRecordName(int type, Class<?> recordTypesClass)`
  Gets the name of the given record type
  `static OmfIndex`
  `readIndex(BinaryReader reader)`
  `static Omf2or4`
  `readInt2Or4(BinaryReader reader, boolean isBig)`
  `static List<OmfRecord>`
  `readRecords(AbstractOmfRecordFactory factory)`
  Reads all the `records` associated with the given `AbstractOmfRecordFactory`
  `static OmfString`
  `readString(BinaryReader reader)`
  Read the OMF string format: 1-byte length, followed by that many ascii characters
  `static DataType`
  `toOmfRecordDataType(OmfRecord record, String name)`
  Converts the given `OmfRecord` to a generic OMF record `DataType`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### CATEGORY_PATH

    public static final String CATEGORY_PATH
    Data type category
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### OmfUtils

    public OmfUtils()

- ## Method Details

  - ### readInt2Or4

    public static Omf2or4 readInt2Or4(BinaryReader reader, boolean isBig) throws IOException
    Throws:
      `IOException`

  - ### readIndex

    public static OmfIndex readIndex(BinaryReader reader) throws IOException
    Throws:
      `IOException`

  - ### readString

    public static OmfString readString(BinaryReader reader) throws IOException
    Read the OMF string format: 1-byte length, followed by that many ascii characters
    Parameters:
      `reader` - A `BinaryReader` positioned at the start of the string
    Returns:
      the read OMF string
    Throws:
      `IOException` - if an IO-related error occurred

  - ### getRecordName

    public static final String getRecordName(int type, Class<?> recordTypesClass)
    Gets the name of the given record type
    Parameters:
      `type` - The record type
      `recordTypesClass` - The class that contains accessible OMF type fields
    Returns:
      The name of the given record type

  - ### toOmfRecordDataType

    public static DataType toOmfRecordDataType(OmfRecord record, String name)
    Converts the given `OmfRecord` to a generic OMF record `DataType`
    Parameters:
      `record` - The OMF record to convert
      `name` - The name of the OMF record
    Returns:
      A `DataType` for the given OMF record

  - ### readRecords

    public static List<OmfRecord> readRecords(AbstractOmfRecordFactory factory) throws OmfException, IOException
    Reads all the `records` associated with the given `AbstractOmfRecordFactory`
    Parameters:
      `factory` - The `AbstractOmfRecordFactory`
    Returns:
      A `List` of read `records`
    Throws:
      `IOException` - if there was an IO-related error
      `OmfException` - if there was a problem with the OMF specification

  - ### filterRecords

    public static <T> Stream<T> filterRecords(List<OmfRecord> records, Class<T> classType)
    Returns a `Stream` of `records` that match the given class type
    Type Parameters:
      `T` - The class type
    Parameters:
      `records` - The `List` of all `records`
      `classType` - The class type to match on
    Returns:
      A `Stream` of matching (@link OmfRecord records}