Class Exporter

java.lang.Object
ghidra.app.util.exporter.Exporter
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
AsciiExporter, BinaryExporter, CppExporter, GdtExporter, GzfExporter, HtmlExporter, IntelHexExporter, OriginalFileExporter, XmlExporter

public abstract class Exporter extends Object implements ExtensionPoint
The interface that all exporters must implement.
  • Field Details

  • Constructor Details

    • Exporter

      protected Exporter(String name, String extension, HelpLocation help)
      Constructs a new exporter.
      Parameters:
      name - the display name of this exporter
      extension - the default extension for this exporter
      help - the help location for this exporter
  • Method Details

    • getName

      public final String getName()
      Returns the display name of this exporter.
      Returns:
      the display name of this exporter
    • getDefaultFileExtension

      public final String getDefaultFileExtension()
      Returns the default extension for this exporter. For example, .html for .xml.
      Returns:
      the default extension for this exporter
    • getHelpLocation

      public final HelpLocation getHelpLocation()
      Returns the help location for this exporter. It should return null only if no help documentation exists.
      Returns:
      the help location for this exporter
    • getMessageLog

      public final MessageLog getMessageLog()
      Returns the message log the may have been created during an export. The message log is used to log warnings and other non-critical messages.
      Returns:
      the message log
    • setExporterServiceProvider

      public final void setExporterServiceProvider(ServiceProvider provider)
      Sets the exporter service provider.
      Parameters:
      provider - the exporter service provider
    • canExportDomainObject

      public boolean canExportDomainObject(Class<? extends DomainObject> domainObjectClass)
      Returns true if this exporter is capable of exporting the given domain file/object content type. For example, some exporters have the ability to export programs, other exporters can export project data type archives.

      NOTE: This method should only be used as a preliminary check, if neccessary, to identify exporter implementations that are capable of handling a specified content type/class. Prior to export a final check should be performed based on the export or either a DomainFile or DomainObject:

      DomainFile export - the method canExportDomainFile(DomainFile) should be used to verify a direct project file export is possible using the export(File, DomainFile, TaskMonitor) method.

      DomainObject export - the method canExportDomainObject(DomainObject) should be used to verify an export of a specific object is possible using the export(File, DomainObject, AddressSetView, TaskMonitor) method. avoid opening DomainFile when possible.

      Parameters:
      domainObjectClass - the class of the domain object to test for exporting.
      Returns:
      true if this exporter knows how to export the given domain object type.
    • canExportDomainFile

      public boolean canExportDomainFile(DomainFile domainFile)
      Returns true if exporter can export the specified DomainFile without instantiating a DomainObject. This method should be used prior to exporting using the export(File, DomainFile, TaskMonitor) method. All exporter capable of a DomainFile export must also support a export of a DomainObject so that any possible data modification/upgrade is included within resulting export.
      Parameters:
      domainFile - domain file
      Returns:
      true if export can occur else false if not
    • canExportDomainObject

      public boolean canExportDomainObject(DomainObject domainObject)
      Returns true if this exporter knows how to export the given domain object considering any constraints based on the specific makeup of the object. This method should be used prior to exporting using the export(File, DomainObject, AddressSetView, TaskMonitor) method.
      Parameters:
      domainObject - the domain object to test for exporting.
      Returns:
      true if this exporter knows how to export the given domain object.
    • supportsAddressRestrictedExport

      public boolean supportsAddressRestrictedExport()
      Returns true if this exporter can perform a restricted export of a DomainObject based upon a specified AddressSetView.
      Returns:
      true if this exporter can export less than the entire domain file.
    • getOptions

      public abstract List<Option> getOptions(DomainObjectService domainObjectService)
      Returns the available options for this exporter. The program is needed because some exporters may have options that vary depending on the specific program being exported.
      Parameters:
      domainObjectService - a service for retrieving the applicable domainObject.
      Returns:
      the available options for this exporter
    • setOptions

      public abstract void setOptions(List<Option> options) throws OptionException
      Sets the options. This method is not for defining the options, but rather it is for setting the values of options. If invalid options are passed in, then OptionException should be thrown.
      Parameters:
      options - the option values for this exporter
      Throws:
      OptionException - if invalid options are passed in
    • export

      public abstract boolean export(File file, DomainObject domainObj, AddressSetView addrSet, TaskMonitor monitor) throws ExporterException, IOException
      Actually does the work of exporting a DomainObject. Export will include all saved and unsaved modifications which may have been made to the object.
      Parameters:
      file - the output file to write the exported info
      domainObj - the domain object to export
      addrSet - the address set if only a portion of the program should be exported NOTE: see supportsAddressRestrictedExport().
      monitor - the task monitor
      Returns:
      true if the program was successfully exported; otherwise, false. If the program was not successfully exported, the message log should be checked to find the source of the error.
      Throws:
      ExporterException - if export error occurs
      IOException - if an IO error occurs
    • export

      public boolean export(File file, DomainFile domainFile, TaskMonitor monitor) throws ExporterException, IOException
      Actually does the work of exporting a domain file, if supported (see canExportDomainFile(DomainFile)). Export is performed without instantiation of a DomainObject.
      Parameters:
      file - the output file to write the exported info
      domainFile - the domain file to be exported (e.g., packed DB file)
      monitor - the task monitor
      Returns:
      true if the file was successfully exported; otherwise, false. If the file was not successfully exported, the message log should be checked to find the source of the error.
      Throws:
      ExporterException - if export error occurs
      IOException - if an IO error occurs
    • toString

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