org.apache.commons.compress
Class AbstractArchive

java.lang.Object
  extended by org.apache.commons.compress.PackableObject
      extended by org.apache.commons.compress.AbstractArchive
All Implemented Interfaces:
Archive
Direct Known Subclasses:
TarArchive, ZipArchive

public abstract class AbstractArchive
extends PackableObject
implements Archive

Abstract implementation of an archiver


Field Summary
 
Fields inherited from class org.apache.commons.compress.PackableObject
CHOOSE_EXTENSION, CHOOSE_NAME
 
Constructor Summary
AbstractArchive()
           
 
Method Summary
 void add(ArchiveEntry archiveEntry)
          Adds a FileInputStream to the internal filelist for a possible pack-operation
 void add(File file)
          Adds a file to the internal filelist for a possible pack-operation
 void close()
          Closes this archiver and all internal streams.
protected abstract  void doSave(OutputStream output)
          Specific implementation of the save opteration.
protected abstract  void doUnpack(File unpackDir)
          Specific implementation of the unpack opteration.
 File getArchive()
          Returns the archive file and null, if this archiver has not been saved yet or there has not been set an archive manually.
 Iterator getEntryIterator()
          Get an iterator of ArchiveEntrys which shall be archived
 void save(File output)
          Compresses the file with the given String as a filename
 void save(OutputStream output)
          Packs a file.
 void setArchive(File file)
          Sets an Archive for manipulating.
 void unpack(File unpackDir)
          Unpacks to the specified directory
 
Methods inherited from class org.apache.commons.compress.PackableObject
getDefaultFileExtension, getHeader, getName, identifyByHeader, isPackableWith
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractArchive

public AbstractArchive()
Method Detail

save

public void save(File output)
          throws ArchiveException
Compresses the file with the given String as a filename

Specified by:
save in interface Archive
Throws:
ArchiveException - if there is no destination file or files to be packed
See Also:
Archive.save(OutputStream)

save

public void save(OutputStream output)
          throws ArchiveException
Description copied from interface: Archive
Packs a file. The destination filename must be set manually with setDestinationFile(...). There must be at least 1 file to be packed.

Specified by:
save in interface Archive
Throws:
ArchiveException - if there is no destination file or files to be packed

doSave

protected abstract void doSave(OutputStream output)
                        throws ArchiveException
Specific implementation of the save opteration.

Parameters:
output - - stream to archive to
Throws:
ArchiveException

getArchive

public File getArchive()
Description copied from interface: Archive
Returns the archive file and null, if this archiver has not been saved yet or there has not been set an archive manually.

Specified by:
getArchive in interface Archive
Returns:
the archiver, or null

setArchive

public void setArchive(File file)
Description copied from interface: Archive
Sets an Archive for manipulating. An archive is set if someone saves an Archive or calls getInstance(...) with an archive.

Specified by:
setArchive in interface Archive
Parameters:
file - the file to manipulate

add

public void add(File file)
         throws FileNotFoundException
Description copied from interface: Archive
Adds a file to the internal filelist for a possible pack-operation

Specified by:
add in interface Archive
Throws:
FileNotFoundException

add

public void add(ArchiveEntry archiveEntry)
Description copied from interface: Archive
Adds a FileInputStream to the internal filelist for a possible pack-operation

Specified by:
add in interface Archive

getEntryIterator

public Iterator getEntryIterator()
Description copied from interface: Archive
Get an iterator of ArchiveEntrys which shall be archived

Specified by:
getEntryIterator in interface Archive
Returns:
the iterator

unpack

public void unpack(File unpackDir)
            throws UnpackException
Description copied from interface: Archive
Unpacks to the specified directory

Specified by:
unpack in interface Archive
Parameters:
unpackDir - to unpack
Throws:
UnpackException - if an unpack error occurs

doUnpack

protected abstract void doUnpack(File unpackDir)
                          throws UnpackException
Specific implementation of the unpack opteration.

Parameters:
unpackDir - dir, to unpack to
Throws:
UnpackException

close

public void close()
           throws IOException
Description copied from interface: Archive
Closes this archiver and all internal streams.

Specified by:
close in interface Archive
Throws:
IOException


Copyright © 2011 Apache Software Foundation. All Rights Reserved.