org.at4j.util.archive
Class ArchiveExtractor

java.lang.Object
  extended by org.at4j.util.archive.ArchiveExtractor

public class ArchiveExtractor
extends Object

This object can be used to extract some or all of the entries from an archive to a directory. No metadata is copied to the extracted entries. Symbolic links are not supported and they will be ignored.

An extraction operation is configured with an optional ExtractSpecification object. It can be used to fine-tune the extraction process.

Since:
1.0
Author:
Karl Gustafsson
See Also:
TarExtractor

Constructor Summary
ArchiveExtractor(Archive<?,?> archive)
          Create a new archive extractor that extracts contents from the supplied archive.
 
Method Summary
 void extract(DirectoryView target)
          Extract all entries in the archive to the supplied directory.
 void extract(DirectoryView target, ExtractSpecification spec)
          Extract the archive entries that match the supplied filter to the target directory.
 void extract(File target)
          Extract all entries in the archive to the supplied directory.
 void extract(File target, ExtractSpecification spec)
          Extract the archive entries that match the supplied filter to the target directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveExtractor

public ArchiveExtractor(Archive<?,?> archive)
Create a new archive extractor that extracts contents from the supplied archive.

Parameters:
archive - The archive to extract contents from.
Method Detail

extract

public void extract(DirectoryView target)
             throws WrappedIOException
Extract all entries in the archive to the supplied directory.

Parameters:
target - The target directory. If this is a view, all its view settings will be ignored.
Throws:
WrappedIOException - On I/O errors.

extract

public void extract(DirectoryView target,
                    ExtractSpecification spec)
             throws WrappedIOException
Extract the archive entries that match the supplied filter to the target directory.

Parameters:
target - The target directory. If this is a view, all its view settings will be ignored.
spec - The specification object that contains configuration for this extraction. ArchiveEntryFilter.
Throws:
WrappedIOException - On I/O errors.

extract

public void extract(File target)
             throws WrappedIOException,
                    EntityNotFoundException,
                    NotADirectoryException
Extract all entries in the archive to the supplied directory.

Parameters:
target - The target directory. This must be an existing directory.
Throws:
WrappedIOException - On I/O errors.
EntityNotFoundException - If the target directory does not exist.
NotADirectoryException - If the target exists but is not a directory.

extract

public void extract(File target,
                    ExtractSpecification spec)
             throws WrappedIOException,
                    EntityNotFoundException,
                    NotADirectoryException
Extract the archive entries that match the supplied filter to the target directory.

Parameters:
target - The target directory. This must be an existing directory.
spec - The specification object that contains configuration for this extraction.
Throws:
WrappedIOException - On I/O errors.
EntityNotFoundException - If the target directory does not exist.
NotADirectoryException - If the target exists but is not a directory.