Interface DumpHandler

All Known Implementing Classes:
AbstractDumpHandler, CronJobDumpHandler, DefaultDumpHandler

public interface DumpHandler
Extensions of this interface handle the storage of unresolved value lines while an import process. An import process can result in an amount of unresolved lines which can be resolved by importing them again maybe. Therefore they have to be stored in a string, file, media, .. (each kind have advantages and disadvantages).

So an extension of this handler provides a writer object to a dump storage using getWriterOfCurrentDump() after initialization using init(). After writing all unresolved value lines using the writer object, the import process calls switchDump, to start a new import pass with the dump as input. After first call of switchDump, the getReaderOfLastDump() will return a reader object of the dump storage used before the switch for reading that dump storage as input of the next import cycle.
If dump handling is needed anymore, a call of finish() has to be called.

Visualization:

 call of init()                   -> dump storage A will be created
 call of getWriterOfCurrentDump() -> gets writer object of A
 call of switchDump()             -> dump storage B will be created
 call of getWriterOfCurrentDump() -> gets writer object of B
 call of getReaderOfLastDump      -> gets reader object of A
 call of switchDump()             -> dump storage C will be created
 call of getWriterOfCurrentDump() -> gets writer object of C
 call of getReaderOfLastDump      -> gets reader object of B
 call of finish()                 -> cleans dumps
 
  • Method Details

    • init

      void init() throws IOException
      Initializes the handler by creating the first dump storage and providing a writer object to that storage when calling getWriterOfCurrentDump().
      Throws:
      IOException - error while storage creation
    • switchDump

      void switchDump() throws ImpExException
      References the 'current' dump storage as 'last' dump storage (getReaderOfLastDump() now provides a reader object to that storage) and creates a new 'current' dump storage (getWriterOfCurrentDump() now provides a writer object to that storage). If there was a storage referenced by 'last' it will be deleted.
      Throws:
      ImpExException - error while storage handling
    • finish

      void finish(boolean saveCurrentDump)
      Deletes last dump storage definitely and current one if given flag is set.
      Parameters:
      saveCurrentDump - should the current storage be deleted
    • getReaderOfLastDump

      CSVReader getReaderOfLastDump()
      Gets a reader object to the last dump storage.
      Returns:
      reader to last dump storage
    • getWriterOfCurrentDump

      CSVWriter getWriterOfCurrentDump()
      Gets a writer object to the current dump storage.
      Returns:
      writer to current dump storage
    • getDumpAsMedia

      ImpExMedia getDumpAsMedia()
      Gets the current dump as media object.
      Returns:
      current dump as media
    • getDumpAsFile

      File getDumpAsFile()
      Gets the current dump as file.
      Returns:
      current dump as file
    • getDumpAsString

      String getDumpAsString()
      Gets the current dump as text.
      Returns:
      current dump as text