# Class: com.pnfsoftware.jeb.core.units.code.DecompilerExporter

Helper class used to decompile and export to source files all or a subset of classes or methods of a code unit. 

 Example: export all top\-level items to an output folder:  

```

 IDecompilerUnit decomp = ...; // retrieved from the current IRuntimeProject
 File outdir = ...;
 DecompilerExporter exp = decomp.getExporter();
 exp.setOutputFolder(outdir, false);
 exp.setMethodTimeout(60_000L);  // safety
 exp.setTotalTimeout(15 * 60_000L);  // safety
 exp.setCallback(new ProgressCallbackAdapter() {
     @Override
     public void message(String msg) {
         System.out.println(msg);
     }
 });
 boolean success = exp.process();
 System.out.println("Errors: " + exp.getErrors());
 
```

## Constructor: DecompilerExporter
- parameter: `decompiler`, type: `com.pnfsoftware.jeb.core.units.code.IDecompilerUnit`

Description: Create an exporter with default settings.
parameter: decompiler: a decompiler

## Protected Field: callback
Type: `com.pnfsoftware.jeb.util.base.IProgressCallback`

## Protected Field: decomp
Type: `com.pnfsoftware.jeb.core.units.code.IDecompilerUnit`

## Protected Field: discardDecompiledItemsAfterProcessing
Type: `boolean`

## Protected Field: errormap
Type: `java.util.Map<java.lang.String,java.lang.String>`

## Protected Field: headerString
Type: `java.lang.String`

## Protected Field: methodTimeoutMs
Type: `long`

## Protected Field: outputFolder
Type: `java.io.File`

## Protected Field: pattern
Type: `java.util.regex.Pattern`

## Protected Field: totalTimeoutMs
Type: `long`

## Protected Field: usesCustomDecompWriter
Type: `boolean`

## Protected Field: writeCount
Type: `java.util.concurrent.atomic.AtomicInteger`

## Protected Field: writeErrorCount
Type: `java.util.concurrent.atomic.AtomicInteger`

## Protected Static Field: logger
Type: `com.pnfsoftware.jeb.util.logging.ILogger`

## Protected Method: customizeOptions
- parameter: `decompilingClasses`, type: `boolean`
- parameter: `optbld`, type: `com.pnfsoftware.jeb.core.units.code.DecompilationOptions.Builder`

Description: Optional method used to customize the options of the decompilation context. The custom implementation may modify or set new options. The default implementation does nothing.
parameter: decompilingClasses: true if the exporter will decompile classes; false if it will            decompile methods
parameter: optbld: the current option builder

## Method: export
- return type: `boolean`

Description: A synonym for [#process()](#process()).

## Protected Method: generateClassFileName
- parameter: `address`, type: `java.lang.String`
- return type: `java.lang.String`


## Protected Method: generateMethodFileName
- parameter: `address`, type: `java.lang.String`
- return type: `java.lang.String`


## Method: getCallback
- return type: `com.pnfsoftware.jeb.util.base.IProgressCallback`


## Method: getDecompiler
- return type: `com.pnfsoftware.jeb.core.units.code.IDecompilerUnit`


## Method: getErrors
- return type: `java.util.Map<java.lang.String,java.lang.String>`

Description: Retrieve a map "address \-\> error string" for all methods that failed the decompilation. Call after [#process()](#process()).
return: 

## Method: getGeneratedFileCount
- return type: `java.lang.Integer`

Description: Retrieve the number of generated source files.
return: 

## Method: getHeaderString
- return type: `java.lang.String`


## Method: getMethodTimeout
- return type: `long`


## Method: getOutputFolder
- return type: `java.io.File`


## Method: getSignaturePattern
- return type: `java.util.regex.Pattern`


## Method: getTotalTimeout
- return type: `long`


## Method: isKeepDecompiledItemsAfterProcessing
- return type: `boolean`


## Method: process
- return type: `boolean`

Description: Decompile and export all meaningful elements. This is the recommended method to call. Top\-level classes and their constituents will be exported; orphaned methods and other items will be exported as well. 

 If an output folder was specified, the resulting source files will be stored in a folder hierarchy that matches their namespace or package name.
return: true if no error occurred; false if some errors occurred

## Method: processMethods
- return type: `boolean`

Description: Decompile and export all internal methods. Refer to [#processTopLevelClasses()](#processTopLevelClasses()) to export classes hierarchically. 

 If an output folder was specified, the resulting source files will be stored in that folder. No folder hierarchy is created. File names are uniquely derived from method signatures.
return: true if no error occurred; false if some errors occurred

## Method: processTopLevelClasses
- return type: `boolean`

Description: Decompile and export all top\-level classes \(i.e., non member classes\). 

 If an output folder was specified, the resulting source files will be stored in a folder hierarchy that matches their namespace or package name.
return: true if no error occurred; false if some errors occurred

## Protected Method: reset


## Method: setCallback
- parameter: `callback`, type: `com.pnfsoftware.jeb.util.base.IProgressCallback`

Description: Set an optional callback to receive progress information on the decompilation.
parameter: callback: 

## Method: setDiscardDecompiledItemsAfterProcessing
- parameter: `discardDecompiledItemsAfterProcessing`, type: `boolean`

Description: Specify whether decompiled items should be kept or discarded after the decompilation process is complete. Unless you are planning to examine decompiled items later, it is recommended to discard them.
parameter: discardDecompiledItemsAfterProcessing: 

## Method: setHeaderString
- parameter: `s`, type: `java.lang.String`

Description: Set an optional single\-line header string, prepended to all decompiled classes. The default header string is: `Decompiled by JEB v[VERSION] `
parameter: s: 

## Method: setMethodTimeout
- parameter: `methodTimeoutMs`, type: `long`

Description: Set an optional timeout for method decompilation.
parameter: methodTimeoutMs: 

## Method: setOutputFolder
- parameter: `folder`, type: `java.io.File`


## Method: setOutputFolder
- parameter: `folder`, type: `java.io.File`
- parameter: `discardDecompiledItemsAfterProcessing`, type: `java.lang.Boolean`

Description: Set an optional output folder. If the folder exists and contents is already present, it will NOT be removed.
parameter: folder: 
parameter: discardDecompiledItemsAfterProcessing: optional; if non\-null, also update            [#setDiscardDecompiledItemsAfterProcessing(boolean)](#setDiscardDecompiledItemsAfterProcessing(boolean))
throws: if some error occurred when creating the output folder

## Method: setSignaturePattern
- parameter: `pattern`, type: `java.util.regex.Pattern`

Description: Set an optional matcher for classes or methods to be decompiled.
parameter: pattern: a regex pattern

## Method: setTotalTimeout
- parameter: `totalTimeoutMs`, type: `long`

Description: Set an optional timeout for the entire decompilation process.
parameter: totalTimeoutMs: 

## Protected Method: writeClassDecompilation
- parameter: `addr`, type: `java.lang.String`


## Protected Method: writeMethodDecompilation
- parameter: `addr`, type: `java.lang.String`


