Package ghidra.plugins.importer.batch

# Class BatchInfo

java.lang.Object
ghidra.plugins.importer.batch.BatchInfo

public class BatchInfo extends Object
This is the main state of a batch import task, containing the segregated groupings of applications.

This class also handles populating the batch groups by recursively descending into files and the contents of those files.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MAXDEPTH_DEFAULT`
  `static final int`
  `MAXDEPTH_UNLIMITED`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BatchInfo()`
  Creates a new BatchInfo object with a default `maxDepth`.
  `BatchInfo(int maxDepth)`
  Creates a new BatchInfo object using the specified maxDepth.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `addFile(FSRL fsrl, TaskMonitor taskMonitor)`
  Adds a file to this batch as the direct result of a user action.
  `int`
  `getEnabledCount()`
  Returns the count of applications in enabled `BatchGroup`s...
  `List<BatchGroup>`
  `getGroups()`
  Returns a list of the `BatchGroup`s that have been found when processing the added files.
  `int`
  `getMaxDepth()`
  Maximum depth of containers (ie.
  `int`
  `getTotalCount()`
  Returns the count of how many importable objects (ie.
  `int`
  `getTotalRawCount()`
  Returns the count of how many files were found while processing the source files.
  `List<UserAddedSourceInfo>`
  `getUserAddedSources()`
  Returns the `List` of files added via `addFile(FSRL, TaskMonitor)`.
  `boolean`
  `isSingleApp()`
  Checks the found applications and returns true if only a single binary was found, even if multiple loaders claim it.
  `void`
  `remove(FSRL fsrl)`
  Removes a user-added source file (and all the embedded files inside it) from this batch.
  `void`
  `setMaxDepth(int newMaxDepth)`
  Sets a new max container recursive depth limit for this batch import
  `String`
  `toString()`
  `boolean`
  `wasRecurseTerminatedEarly()`
  Returns true if any of the user source files had containers that were not recursed into because of the `maxDepth` limit.

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

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

- ## Field Details

  - ### MAXDEPTH_UNLIMITED

    public static final int MAXDEPTH_UNLIMITED
    See Also:
      - Constant Field Values

  - ### MAXDEPTH_DEFAULT

    public static final int MAXDEPTH_DEFAULT
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### BatchInfo

    public BatchInfo()
    Creates a new BatchInfo object with a default `maxDepth`.

  - ### BatchInfo

    public BatchInfo(int maxDepth)
    Creates a new BatchInfo object using the specified maxDepth.
    Parameters:
      `maxDepth` - see `maxDepth`.

- ## Method Details

  - ### getGroups

    public List<BatchGroup> getGroups()
    Returns a list of the `BatchGroup`s that have been found when processing the added files.
    Returns:
      `List` of `BatchGroup`s.

  - ### getTotalCount

    public int getTotalCount()
    Returns the count of how many importable objects (ie. `LoadSpec`s) were found.
    Returns:
      count of importable objects.

  - ### getTotalRawCount

    public int getTotalRawCount()
    Returns the count of how many files were found while processing the source files.
    Returns:
      count of files found while processing source files.

  - ### getEnabledCount

    public int getEnabledCount()
    Returns the count of applications in enabled `BatchGroup`s... in other words, the number of objects that would be imported during this batch.
    Returns:
      count of enabled applications.

  - ### remove

    public void remove(FSRL fsrl)
    Removes a user-added source file (and all the embedded files inside it) from this batch.
    Parameters:
      `fsrl` - `FSRL` of the file to remove.

  - ### addFile

    public boolean addFile(FSRL fsrl, TaskMonitor taskMonitor) throws IOException, CancelledException
    Adds a file to this batch as the direct result of a user action.

    If the file is a container for other files, this method will iterate through those child files and recursively try to add them using this method.

    Parameters:
      `fsrl` - `FSRL` of the file to add.
      `taskMonitor` - `TaskMonitor` to watch and update with progress.
    Returns:
      boolean true if something in the file produced something to import.
    Throws:
      `IOException` - if io error when reading files.
      `CancelledException` - if user cancels.

  - ### wasRecurseTerminatedEarly

    public boolean wasRecurseTerminatedEarly()
    Returns true if any of the user source files had containers that were not recursed into because of the `maxDepth` limit.
    Returns:
      true if any of the user source files had containers that were not recursed into because of the `maxDepth` limit.

  - ### isSingleApp

    public boolean isSingleApp()
    Checks the found applications and returns true if only a single binary was found, even if multiple loaders claim it.
    Returns:
      true if single binary and batch is probably not correct importer.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getUserAddedSources

    public List<UserAddedSourceInfo> getUserAddedSources()
    Returns the `List` of files added via `addFile(FSRL, TaskMonitor)`.
    Returns:
      `List` of files added via `addFile(FSRL, TaskMonitor)`.

  - ### getMaxDepth

    public int getMaxDepth()
    Maximum depth of containers (ie. filesystems) to recurse into when processing a file added by the user
    Returns:
      the current maximum depth of containers (ie. filesystems) to recurse into when processing a file added by the user.

  - ### setMaxDepth

    public void setMaxDepth(int newMaxDepth)
    Sets a new max container recursive depth limit for this batch import

    Doing this requires rescanning all original user-added source files and stopping at the new max depth.

    Parameters:
      `newMaxDepth` - new value for the max depth