Package ghidra.app.util.exporter
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
The interface that all exporters must implement.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Exporter
(String name, String extension, HelpLocation help) Constructs a new exporter. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canExportDomainFile
(DomainFile domainFile) Returns true if exporter can export the specifiedDomainFile
without instantiating aDomainObject
.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.boolean
canExportDomainObject
(Class<? extends DomainObject> domainObjectClass) Returns true if this exporter is capable of exporting the given domain file/object content type.boolean
export
(File file, DomainFile domainFile, TaskMonitor monitor) Actually does the work of exporting a domain file, if supported (seecanExportDomainFile(DomainFile)
).abstract boolean
export
(File file, DomainObject domainObj, AddressSetView addrSet, TaskMonitor monitor) Actually does the work of exporting aDomainObject
.final String
Returns the default extension for this exporter.final HelpLocation
Returns the help location for this exporter.final MessageLog
Returns the message log the may have been created during an export.final String
getName()
Returns the display name of this exporter.getOptions
(DomainObjectService domainObjectService) Returns the available options for this exporter.final void
setExporterServiceProvider
(ServiceProvider provider) Sets the exporter service provider.abstract void
setOptions
(List<Option> options) Sets the options.boolean
Returns true if this exporter can perform a restricted export of aDomainObject
based upon a specifiedAddressSetView
.final String
toString()
-
Field Details
-
EMPTY_OPTIONS
-
log
-
provider
-
-
Constructor Details
-
Exporter
Constructs a new exporter.- Parameters:
name
- the display name of this exporterextension
- the default extension for this exporterhelp
- the help location for this exporter
-
-
Method Details
-
getName
Returns the display name of this exporter.- Returns:
- the display name of this exporter
-
getDefaultFileExtension
Returns the default extension for this exporter. For example, .html for .xml.- Returns:
- the default extension for this exporter
-
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
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
Sets the exporter service provider.- Parameters:
provider
- the exporter service provider
-
canExportDomainObject
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
orDomainObject
:DomainFile
export - the methodcanExportDomainFile(DomainFile)
should be used to verify a direct project file export is possible using theexport(File, DomainFile, TaskMonitor)
method.DomainObject
export - the methodcanExportDomainObject(DomainObject)
should be used to verify an export of a specific object is possible using theexport(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
Returns true if exporter can export the specifiedDomainFile
without instantiating aDomainObject
. This method should be used prior to exporting using theexport(File, DomainFile, TaskMonitor)
method. All exporter capable of aDomainFile
export must also support a export of aDomainObject
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
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 theexport(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 aDomainObject
based upon a specifiedAddressSetView
.- Returns:
- true if this exporter can export less than the entire domain file.
-
getOptions
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
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 aDomainObject
. 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 infodomainObj
- the domain object to exportaddrSet
- the address set if only a portion of the program should be exported NOTE: seesupportsAddressRestrictedExport()
.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 occursIOException
- 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 (seecanExportDomainFile(DomainFile)
). Export is performed without instantiation of aDomainObject
.- Parameters:
file
- the output file to write the exported infodomainFile
- 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 occursIOException
- if an IO error occurs
-
toString
-