com.zeroturnaround.liverebel.util
Class ArchiveConverter

java.lang.Object
  extended by com.zeroturnaround.liverebel.util.ArchiveConverter

public class ArchiveConverter
extends Object

Converts archive files towards specific formats.


Constructor Summary
ArchiveConverter(File archive)
          Create a new archive converter instance to convert from a particular file.
 
Method Summary
 void cleanup()
          Clean up any temporary resources that have been created during the archive conversion process.
 File ensureZipArchive()
          Tries its best to convert the archive that was provided in the constructor towards a zip file.
 Collection<File> getTempFiles()
          Return the temporary files that have been used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveConverter

public ArchiveConverter(File archive)
Create a new archive converter instance to convert from a particular file.

Parameters:
archive - the existing archive file to convert from; null references are supported and will result into no-ops from any of the other methods in this class
Method Detail

ensureZipArchive

public File ensureZipArchive()
Tries its best to convert the archive that was provided in the constructor towards a zip file.

First it checks if the provided archive is already a zip file, in that case this method is a no-op and the archive file is returned, unchanged, without any side-effects.

During the conversion process it's possible that temporary resources are created. It's therefore important to always call the cleanup() method when a file instance was returned by this method, after you've finished using the returned file. In case null is returned, cleanup isn't necessary as it will have been done automatically.

Returns:
a File that is a valid zip archive; or null if for any reason the conversion failed
See Also:
cleanup()

getTempFiles

public Collection<File> getTempFiles()
Return the temporary files that have been used.

Returns:
the collection of temporary files that have been used

cleanup

public void cleanup()
Clean up any temporary resources that have been created during the archive conversion process. Note that calling cleanup() might invalidate the file that was returned by other methods, hence you should only cleanup when you don't need the converted files anymore.



Copyright © 2013. All Rights Reserved.