de.unkrig.commons.file.org.apache.commons.compress.archivers.cpio
Class CpioArchiveFormat

java.lang.Object
  extended by de.unkrig.commons.file.org.apache.commons.compress.archivers.cpio.CpioArchiveFormat
All Implemented Interfaces:
ArchiveFormat

public final class CpioArchiveFormat
extends java.lang.Object
implements ArchiveFormat

Representation of the 'ar' archive format.


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.
static ArchiveFormat get()
          Required by ArchiveFormatFactory.
 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.
 java.lang.String toString()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public static ArchiveFormat get()
Required by ArchiveFormatFactory.


getName

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

isArchiveFileName

public boolean isArchiveFileName(java.lang.String fileName)
Specified by:
isArchiveFileName in interface ArchiveFormat
Returns:
Whether the given fileName is typical for this ArchiveFormat

getArchiveFileName

public java.lang.String getArchiveFileName(java.lang.String fileName)
Description copied from interface: ArchiveFormat
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'.

Specified by:
getArchiveFileName in interface ArchiveFormat

archiveInputStream

public org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream(java.io.InputStream is)
Specified by:
archiveInputStream in interface ArchiveFormat
Returns:
An ArchiveInputStream for this format which reads from the given input stream

open

public org.apache.commons.compress.archivers.ArchiveInputStream open(java.io.File archiveFile)
                                                              throws java.io.IOException
Description copied from interface: ArchiveFormat
Opens an existing archive file for reading.

Specified by:
open in interface ArchiveFormat
Returns:
An ArchiveInputStream for this format which reads from the given archiveFile
Throws:
java.io.IOException

archiveOutputStream

public org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream(java.io.OutputStream os)
Specified by:
archiveOutputStream in interface ArchiveFormat
Returns:
An ArchiveOutputStream for this format which writes to the given output stream

create

public org.apache.commons.compress.archivers.ArchiveOutputStream create(java.io.File archiveFile)
                                                                 throws java.io.IOException
Description copied from interface: ArchiveFormat
Creates a new archive file.

Specified by:
create in interface ArchiveFormat
Returns:
An ArchiveOutputStream for this format which writes to the given archiveFile
Throws:
java.io.IOException

writeEntry

public 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
Description copied from interface: ArchiveFormat
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

Specified by:
writeEntry in interface ArchiveFormat
Parameters:
archiveOutputStream - Must match this ArchiveFormat
writeContents - Writes the entry's contents to the 'subject' output stream
Throws:
java.io.IOException

writeEntry

public 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
Description copied from interface: ArchiveFormat
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

Specified by:
writeEntry in interface ArchiveFormat
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.io.IOException

matches

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object