Class CompressorFactory


  • public final class CompressorFactory
    extends java.lang.Object
    Factory for creating Compressor instances by a given compression algorithm. Use the constants in this class to pass to the factory method.
    • Method Detail

      • createCompressor

        public static Compressor createCompressor​(java.io.File file)
                                           throws java.lang.IllegalArgumentException
        Probes the given File for its file type and creates a Compressor based on this file type.
        Parameters:
        file - the file to check.
        Returns:
        a new Compressor instance
        Throws:
        java.lang.IllegalArgumentException - if the given file is not a known compressed file type
      • createCompressor

        public static Compressor createCompressor​(FileType fileType)
                                           throws java.lang.IllegalArgumentException
        Creates a new Compressor for the given FileType.
        Parameters:
        fileType - the file type to create the compressor for
        Returns:
        a new Compressor instance
        Throws:
        java.lang.IllegalArgumentException - if the given file type is not a known compression type
      • createCompressor

        public static Compressor createCompressor​(java.lang.String compression)
                                           throws java.lang.IllegalArgumentException
        Creates a compressor from the given compression type.
        Parameters:
        compression - the name of the compression algorithm e.g. "gz" or "bzip2".
        Returns:
        a new Compressor instance for the given compression algorithm
        Throws:
        java.lang.IllegalArgumentException - if the compression type is unknown
      • createCompressor

        public static Compressor createCompressor​(CompressionType compression)
        Creates a compressor from the given CompressionType.
        Parameters:
        compression - the type of the compression algorithm
        Returns:
        a new Compressor instance that uses the specified compression algorithm.