de.esprit.appsuite.io.archive

## Class AbstractArchiveExtractor<C extends ApplicationContext,E extends ArchiveEntry>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.AbstractAsyncExecutable<C>
      - - de.esprit.appsuite.io.archive.AbstractArchiveExtractor<C,E>

- All Implemented Interfaces:
    ApplicationObject<C>, AsyncExecutable<C>, CancellableTask, TaskMonitorSupport, SimpleLogSupport, Dumpable, Executable
  Direct Known Subclasses:
    TarExtractor, ZipExtractor

      public abstract class AbstractArchiveExtractor<C extends ApplicationContext,E extends ArchiveEntry>
      extends AbstractAsyncExecutable<C>

  This class extracts the content of an archive into a given target-directory. Note that progress notification is done by an attached `ProgressInputStream`.
  Author:
    Rainer Buesch

- - ### Field Summary

    - ### Fields inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `childTaskRef, isTestMode, monitorController, resultRef, stateFlag`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractArchiveExtractor(C ctx, LogChannel logCh, java.lang.String taskName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkStreamAccess()`
    `protected java.io.OutputStream` | `createOutputStream(java.io.File outFile)` May be overridden to create a particular FileOutputStream
    `protected void` | `displayArchiveEntry(java.io.InputStream inStream, E entry)` Prints the unix pathname of the entry by default
    `protected void` | `displayHeader(java.lang.String headerInfo)`
    `protected void` | `doOnDirectoryCreated(E entry, java.io.File relativeDir)`
    `protected void` | `doOnFileCreated(E entry, java.io.File file)`
    `protected void` | `doOnFileCreating(E entry)` Passes the relative fileName as argument.
    `void` | `executeAsync()` Contains the code to be executed asynchronously.
    `protected void` | `extractAsDirectory(E entry)`
    `protected void` | `extractToFile(java.io.InputStream inStream, E entry)`
    `protected abstract FileType` | `getArchiveType()`
    `java.io.File` | `getInputFile()`
    `java.io.File` | `getTargetDir()`
    `protected boolean` | `isShouldExtract(E entry)` May be overridden in order to filter which `ArchiveEntry` should be extracted.
    `protected abstract void` | `processArchive()`
    `void` | `setExtractionFilter(ArchiveEntryFilter filter)` Allows to filter what should be extracted.
    `void` | `setInputFile(java.io.File tarInFile)` Sets the input file which must be a ZIP or JAR archive.
    `void` | `setTargetDir(java.io.File targetDir)`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `addMonitor, checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, handleFinish, handleStart, handleSuccess, hasError, hasMonitor, isCancellable, notifyProceeded, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

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

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

    - ### Methods inherited from interface de.esprit.appsuite.launch.ApplicationObject

      `getApplicationContext`

    - ### Methods inherited from interface de.esprit.common.log.SimpleLogSupport

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

- - ### Constructor Detail

    - #### AbstractArchiveExtractor

          protected AbstractArchiveExtractor(C ctx,
                                  LogChannel logCh,
                                  java.lang.String taskName)

  - ### Method Detail

    - #### setInputFile

          public final void setInputFile(java.io.File tarInFile)

      Sets the input file which must be a ZIP or JAR archive.

    - #### getInputFile

          public final java.io.File getInputFile()

    - #### setTargetDir

          public final void setTargetDir(java.io.File targetDir)

    - #### getTargetDir

          public final java.io.File getTargetDir()

    - #### setExtractionFilter

          public final void setExtractionFilter(ArchiveEntryFilter filter)

      Allows to filter what should be extracted.

    - #### executeAsync

          public final void executeAsync()
                                  throws java.lang.Exception

      Description copied from interface: `AsyncExecutable`
      Contains the code to be executed asynchronously. WARNING: This method should never be called directly by the programmer. It rather must be called by `Runnable.run()` for async execution.
      Specified by:
        `executeAsync` in interface `AsyncExecutable<C extends ApplicationContext>`
      Specified by:
        `executeAsync` in class `AbstractAsyncExecutable<C extends ApplicationContext>`
      Throws:
        `java.lang.Exception`
      See Also:
        `for synchronous execution`

    - #### displayHeader

          protected void displayHeader(java.lang.String headerInfo)

    - #### displayArchiveEntry

          protected void displayArchiveEntry(java.io.InputStream inStream,
                                 E entry)
                                      throws java.lang.Exception

      Prints the unix pathname of the entry by default
      Throws:
        `java.lang.Exception`

    - #### createOutputStream

          protected java.io.OutputStream createOutputStream(java.io.File outFile)
                                                     throws java.lang.Exception

      May be overridden to create a particular FileOutputStream
      Throws:
        `java.lang.Exception`

    - #### checkStreamAccess

          protected final void checkStreamAccess()

    - #### isShouldExtract

          protected final boolean isShouldExtract(E entry)

      May be overridden in order to filter which `ArchiveEntry` should be extracted.
      Returns:
        true by default

    - #### extractAsDirectory

          protected void extractAsDirectory(E entry)
                                     throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### extractToFile

          protected void extractToFile(java.io.InputStream inStream,
                           E entry)
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### doOnDirectoryCreated

          protected void doOnDirectoryCreated(E entry,
                                  java.io.File relativeDir)

    - #### doOnFileCreating

          protected void doOnFileCreating(E entry)

      Passes the relative fileName as argument. The absolute name can be constructed if needed like this: new File(getTargetDir(), fileName)

    - #### doOnFileCreated

          protected void doOnFileCreated(E entry,
                             java.io.File file)

    - #### getArchiveType

          protected abstract FileType getArchiveType()

    - #### processArchive

          protected abstract void processArchive()
                                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.