de.unkrig.commons.file.org.apache.commons.compress.archivers
Interface ArchiveFormat

All Known Implementing Classes:
ArArchiveFormat, ArjArchiveFormat, CpioArchiveFormat, DumpArchiveFormat, JarArchiveFormat, SevenZArchiveFormat, TarArchiveFormat, ZipArchiveFormat

public interface ArchiveFormat

Representation of one archive format, e.g. ZIP or TAR. Archive formats are managed by ArchiveFormatFactory.


Method Summary
 org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream(java.io.InputStream is)
           
 org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream(java.io.OutputStream os)
           
 org.apache.commons.compress.archivers.ArchiveOutputStream create(java.io.File archiveFile)
          Creates a new archive file.
 java.lang.String getArchiveFileName(java.lang.String fileName)
          Maps the given fileName to the name that a corresponding archive file would have.
 java.lang.String getName()
           
 boolean isArchiveFileName(java.lang.String fileName)
           
 boolean matches(byte[] signature, int signatureLength)
           
 org.apache.commons.compress.archivers.ArchiveInputStream open(java.io.File archiveFile)
          Opens an existing archive file for reading.
 void writeEntry(org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream, org.apache.commons.compress.archivers.ArchiveEntry archiveEntry, java.lang.String name, ConsumerWhichThrows<java.io.OutputStream,java.io.IOException> writeContents)
          Appends the given archiveEntry with the given contents to the given archiveOutputStream.
 void writeEntry(org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream, java.lang.String name, ConsumerWhichThrows<java.io.OutputStream,java.io.IOException> writeContents)
          Appends an entry with the given contents to the given archiveOutputStream.
 

Method Detail

getName

java.lang.String getName()
Returns:
A short, familiar text which describes this archive format, e.g. '7z', 'zip', 'tar'

isArchiveFileName

boolean isArchiveFileName(java.lang.String fileName)
Returns:
Whether the given fileName is typical for this ArchiveFormat

getArchiveFileName

java.lang.String getArchiveFileName(java.lang.String fileName)
Maps the given fileName to the name that a corresponding archive file would have. This is typically achieved by appending a suffix, like '.7z', '.zip', '.tar'.


archiveInputStream

org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream(java.io.InputStream is)
                                                                            throws org.apache.commons.compress.archivers.StreamingNotSupportedException,
                                                                                   org.apache.commons.compress.archivers.ArchiveException
Returns:
An ArchiveInputStream for this format which reads from the given input stream
Throws:
org.apache.commons.compress.archivers.StreamingNotSupportedException - This archive format does not support streaming
org.apache.commons.compress.archivers.ArchiveException - The contents is invalid for this archive format

open

org.apache.commons.compress.archivers.ArchiveInputStream open(java.io.File archiveFile)
                                                              throws java.io.IOException,
                                                                     org.apache.commons.compress.archivers.ArchiveException
Opens an existing archive file for reading.

Returns:
An ArchiveInputStream for this format which reads from the given archiveFile
Throws:
java.io.IOException
org.apache.commons.compress.archivers.ArchiveException

archiveOutputStream

org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream(java.io.OutputStream os)
                                                                              throws org.apache.commons.compress.archivers.StreamingNotSupportedException,
                                                                                     org.apache.commons.compress.archivers.ArchiveException
Returns:
An ArchiveOutputStream for this format which writes to the given output stream
Throws:
org.apache.commons.compress.archivers.StreamingNotSupportedException - This archive format does not support streaming
org.apache.commons.compress.archivers.ArchiveException - Creation of archives in in this format is not supported

create

org.apache.commons.compress.archivers.ArchiveOutputStream create(java.io.File archiveFile)
                                                                 throws java.io.IOException,
                                                                        org.apache.commons.compress.archivers.ArchiveException
Creates a new archive file.

Returns:
An ArchiveOutputStream for this format which writes to the given archiveFile
Throws:
org.apache.commons.compress.archivers.ArchiveException - Creation of archives in this format is not supported
java.io.IOException

writeEntry

void writeEntry(org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream,
                java.lang.String name,
                ConsumerWhichThrows<java.io.OutputStream,java.io.IOException> writeContents)
                throws java.io.IOException
Appends an entry with the given contents to the given archiveOutputStream. The archive entry is filled with "standard values", except for the entry name.

writeContents is called exactly once unless the name designates a directory entry

Parameters:
archiveOutputStream - Must match this ArchiveFormat
writeContents - Writes the entry's contents to the 'subject' output stream
Throws:
java.lang.IllegalArgumentException - The type of the archiveOutputStream does not match this ArchiveFormat
java.io.IOException

writeEntry

void writeEntry(org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream,
                org.apache.commons.compress.archivers.ArchiveEntry archiveEntry,
                @Nullable
                java.lang.String name,
                ConsumerWhichThrows<java.io.OutputStream,java.io.IOException> writeContents)
                throws java.io.IOException
Appends the given archiveEntry with the given contents to the given archiveOutputStream. If name is not null, then it overrides the name in the archive entry.

If the type of the archiveEntry does not match this ArchiveFormat, then it is automatically converted to the correct type, preserving as much information as possible ('re-archiving').

writeContents is called exactly once unless the archiveEntry is a directory entry

Parameters:
archiveOutputStream - Must match this ArchiveFormat
archiveEntry - May or may not match this ArchiveFormat (see above)
name - Overrides the name in the archiveEntry, or null
writeContents - Writes the entry's contents to the 'subject' output stream
Throws:
java.lang.IllegalArgumentException - The type of the archiveOutputStream does not match this ArchiveFormat
java.io.IOException

matches

boolean matches(byte[] signature,
                int signatureLength)
Returns:
Whether the first few bytes of archive data match what is expected for this format