org.at4j.tar
Class ExtractTarEntryExtractionStrategy

java.lang.Object
  extended by org.at4j.tar.ExtractTarEntryExtractionStrategy
All Implemented Interfaces:
TarEntryExtractionStrategy

public class ExtractTarEntryExtractionStrategy
extends Object
implements TarEntryExtractionStrategy

This strategy object extract Tar entries to a target directory. It is the default entry extraction strategy used by the TarExtractor.

The object can be configured to ignore symbolic link entries. If symbolic links are not ignore, and this object gets a symbolic link entry, it throws a TarFileParseException.

Since:
1.0
Author:
Karl Gustafsson
See Also:
TarExtractSpecification

Constructor Summary
ExtractTarEntryExtractionStrategy(boolean ignoreSymbolicLinks)
           
 
Method Summary
 void extract(TarEntryHeaderData headerData, DataSource src, Directory targetRoot, TarExtractSpecification spec)
          Extract the current Tar entry.
protected  void extractDirectory(TarEntryHeaderData headerData, DataSource src, Directory targetRoot, TarExtractSpecification spec)
           
protected  void extractFile(TarEntryHeaderData headerData, DataSource src, Directory targetRoot, TarExtractSpecification spec)
           
protected  void extractSymbolicLink(TarEntryHeaderData headerData, DataSource src, Directory targetRoot, TarExtractSpecification spec)
           
protected  Directory getDirectory(Directory targetRoot, AbsoluteLocation loc)
           
protected  boolean isIgnoreSymbolicLinks()
           
protected  void skipToNextBlockBoundary(DataSource src, long leastNoToForwardFromLast)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtractTarEntryExtractionStrategy

public ExtractTarEntryExtractionStrategy(boolean ignoreSymbolicLinks)
Method Detail

isIgnoreSymbolicLinks

protected boolean isIgnoreSymbolicLinks()

getDirectory

protected Directory getDirectory(Directory targetRoot,
                                 AbsoluteLocation loc)

skipToNextBlockBoundary

protected void skipToNextBlockBoundary(DataSource src,
                                       long leastNoToForwardFromLast)

extractDirectory

protected void extractDirectory(TarEntryHeaderData headerData,
                                DataSource src,
                                Directory targetRoot,
                                TarExtractSpecification spec)

extractFile

protected void extractFile(TarEntryHeaderData headerData,
                           DataSource src,
                           Directory targetRoot,
                           TarExtractSpecification spec)

extractSymbolicLink

protected void extractSymbolicLink(TarEntryHeaderData headerData,
                                   DataSource src,
                                   Directory targetRoot,
                                   TarExtractSpecification spec)

extract

public void extract(TarEntryHeaderData headerData,
                    DataSource src,
                    Directory targetRoot,
                    TarExtractSpecification spec)
             throws WrappedIOException,
                    TarFileParseException
Description copied from interface: TarEntryExtractionStrategy
Extract the current Tar entry.

Specified by:
extract in interface TarEntryExtractionStrategy
Parameters:
headerData - The Tar entry's header data.
src - The data source. When this method is called, the data source is positioned at the start of the entry data, at a Tar block start. When this method exits, it should be positioned at the next Tar block start, after the entry data.
targetRoot - The root directory of the extraction target directory hierarchy.
spec - The specification for the extraction operation.
Throws:
WrappedIOException - On I/O errors.
TarFileParseException - If the extraction strategy does not know how to deal with the entry.