org.at4j.tar.builder
Class GnuTarEntryStrategy

java.lang.Object
  extended by org.at4j.tar.builder.V7TarEntryStrategy
      extended by org.at4j.tar.builder.UstarEntryStrategy
          extended by org.at4j.tar.builder.GnuTarEntryStrategy
All Implemented Interfaces:
TarEntryStrategy

public class GnuTarEntryStrategy
extends UstarEntryStrategy

This strategy extends the UstarEntryStrategy with the capability to use special headers for long Tar entry paths and link targets.

Gnu Tar headers contain the same data as ustar headers. If the Tar entry path for an entry is too long to fit in the ustar header, this strategy adds a special file name header containing the Tar entry path before the regular ustar entry header.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
GnuTarEntryStrategy()
          Create a new strategy object that will use the platform's default character encoding to encode text values in the Tar entries.
GnuTarEntryStrategy(Charset cs)
          Create a new strategy object that will use the supplied charset for encoding test values in the Tar entries.
 
Method Summary
 void writeDirectory(DataSink out, DirectoryAdapter<?> da, AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
          Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.
 void writeFile(DataSink out, ReadableFile f, AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
          Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.
 void writeFileFromStream(RandomAccess out, InputStream is, AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
          Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.
 
Methods inherited from class org.at4j.tar.builder.UstarEntryStrategy
getHeader, setFileNameInHeader
 
Methods inherited from class org.at4j.tar.builder.V7TarEntryStrategy
addChecksumToHeader, getFileName, getTextEncodingCharset, goToNextBlockBoundary, writeFileToArchive, zeroPadLeft
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GnuTarEntryStrategy

public GnuTarEntryStrategy()
Create a new strategy object that will use the platform's default character encoding to encode text values in the Tar entries.

See Also:
GnuTarEntryStrategy(Charset)

GnuTarEntryStrategy

public GnuTarEntryStrategy(Charset cs)
Create a new strategy object that will use the supplied charset for encoding test values in the Tar entries.

Parameters:
cs - The charset.
See Also:
GnuTarEntryStrategy()
Method Detail

writeFile

public void writeFile(DataSink out,
                      ReadableFile f,
                      AbsoluteLocation location,
                      TarEntrySettings effectiveSettings,
                      Date lastModified)
Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.

Specified by:
writeFile in interface TarEntryStrategy
Overrides:
writeFile in class V7TarEntryStrategy
Parameters:
out - The DataSink to write to. This may be a RandomAccess object. When this method is called, the DataSink is positioned at the start of the entry to write. If this method returns successfully, the DataSink should be positioned at the next block boundary after the written entry (the Tar file is divided into 512-byte blocks).
f - The file to add to the archive. If this file is in a locking FileSystem, it is locked for reading by the caller before this method is called.
location - The absolute location of the entry in the Tar archive.
effectiveSettings - The effective settings for the entry.
lastModified - The time when the file entity was last modified.

writeFileFromStream

public void writeFileFromStream(RandomAccess out,
                                InputStream is,
                                AbsoluteLocation location,
                                TarEntrySettings effectiveSettings,
                                Date lastModified)
Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.

Specified by:
writeFileFromStream in interface TarEntryStrategy
Overrides:
writeFileFromStream in class V7TarEntryStrategy
Parameters:
out - The RandomAccess to write to. When this method is called, the RandomAccess is positioned at the start of the entry to write. If this method returns successfully, the RandomAccess should be positioned at the next block boundary after the written entry (the Tar file is divided into 512-byte blocks).
is - The stream containing the file's data.
location - The absolute location of the entry in the Tar archive.
effectiveSettings - The effective settings for the entry.
lastModified - The time when the file entity was last modified.

writeDirectory

public void writeDirectory(DataSink out,
                           DirectoryAdapter<?> da,
                           AbsoluteLocation location,
                           TarEntrySettings effectiveSettings,
                           Date lastModified)
Override the inherited implementation to prepend the Tar entry header with a special file name header if necessary.

Specified by:
writeDirectory in interface TarEntryStrategy
Overrides:
writeDirectory in class V7TarEntryStrategy
Parameters:
out - The DataSink to write to. This may be a RandomAccess object. When this method is called, the DataSink is positioned at the start of the entry to write. If this method returns successfully, the DataSink should be positioned at the next block boundary after the written entry (the Tar file is divided into 512-byte blocks).
da - The directory to add to the Tar file.
location - The absolute location of the entry in the Tar archive.
effectiveSettings - The effective settings for the entry.
lastModified - The time when the directory entity was last modified.