Class ArchiverFactory


  • public final class ArchiverFactory
    extends java.lang.Object
    Factory for creating Archiver instances by a given archiver type name. Use the constants in this class to pass to the factory method.
    • Method Detail

      • createArchiver

        public static Archiver createArchiver​(java.io.File archive)
                                       throws java.lang.IllegalArgumentException
        Probes the given File for its file type and creates an Archiver based on this file type. If the File has a composite file extension such as ".tar.gz", the created Archiver will also handle ".gz" compression.
        Parameters:
        archive - the archive file to check.
        Returns:
        a new Archiver instance (that may also handle compression)
        Throws:
        java.lang.IllegalArgumentException - if the given file is not a known archive
      • createArchiver

        public static Archiver createArchiver​(FileType fileType)
        Creates an Archiver that handles the given FileType. The Archiver may handle compression inherently, if the FileType uses a compression type, such as ".tgz" might.
        Parameters:
        fileType - the file type
        Returns:
        a new Archiver instance (that may also handle compression)
      • createArchiver

        public static Archiver createArchiver​(java.lang.String archiveFormat,
                                              java.lang.String compression)
                                       throws java.lang.IllegalArgumentException
        Creates an Archiver for the given archive format that uses compression.
        Parameters:
        archiveFormat - the archive format e.g. "tar" or "zip"
        compression - the compression algorithm name e.g. "gz"
        Returns:
        a new Archiver instance that also handles compression
        Throws:
        java.lang.IllegalArgumentException - if the archive format or the compression type is unknown
      • createArchiver

        public static Archiver createArchiver​(ArchiveFormat archiveFormat,
                                              CompressionType compression)
        Creates an Archiver for the given archive format that uses compression.
        Parameters:
        archiveFormat - the archive format
        compression - the compression algorithm
        Returns:
        a new Archiver instance that also handles compression
      • createArchiver

        public static Archiver createArchiver​(java.lang.String archiveFormat)
                                       throws java.lang.IllegalArgumentException
        Creates an Archiver for the given archive format.
        Parameters:
        archiveFormat - the archive format e.g. "tar" or "zip"
        Returns:
        a new Archiver instance
        Throws:
        java.lang.IllegalArgumentException - if the archive format is unknown
      • createArchiver

        public static Archiver createArchiver​(ArchiveFormat archiveFormat)
        Creates an Archiver for the given archive format.
        Parameters:
        archiveFormat - the archive format
        Returns:
        a new Archiver instance