/** * Probes the given {@link File} for its file type and creates a {@link Compressor} based on this file type. * * @param file the file to check. * @return a new Compressor instance * @throws IllegalArgumentException if the given file is not a known compressed file type */ public static Compressor createCompressor(File file) throws IllegalArgumentException { FileType fileType = FileType.get(file); if (fileType == FileType.UNKNOWN) { throw new IllegalArgumentException("Unknown file extension " + file.getName()); } return createCompressor(fileType); }
/** * Probes the given {@link File} for its file type and creates a {@link Compressor} based on this file type. * * @param file the file to check. * @return a new Compressor instance * @throws IllegalArgumentException if the given file is not a known compressed file type */ public static Compressor createCompressor(File file) throws IllegalArgumentException { FileType fileType = FileType.get(file); if (fileType == FileType.UNKNOWN) { throw new IllegalArgumentException("Unknown file extension " + file.getName()); } return createCompressor(fileType); }
/** * Creates a new {@link Compressor} for the given {@link FileType}. * * @param fileType the file type to create the compressor for * @return a new Compressor instance * @throws IllegalArgumentException if the given file type is not a known compression type */ public static Compressor createCompressor(FileType fileType) throws IllegalArgumentException { if (fileType == FileType.UNKNOWN) { throw new IllegalArgumentException("Unknown file type"); } if (fileType.isCompressed()) { return createCompressor(fileType.getCompressionType()); } else { throw new IllegalArgumentException("Unknown compressed file type " + fileType); } }
/** * Creates a compressor from the given compression type. * * @param compression the name of the compression algorithm e.g. "gz" or "bzip2". * @return a new {@link Compressor} instance for the given compression algorithm * @throws IllegalArgumentException if the compression type is unknown */ public static Compressor createCompressor(String compression) throws IllegalArgumentException { if (!CompressionType.isValidCompressionType(compression)) { throw new IllegalArgumentException("Unkonwn compression type " + compression); } return createCompressor(CompressionType.fromString(compression)); }
/** * Creates a compressor from the given compression type. * * @param compression the name of the compression algorithm e.g. "gz" or "bzip2". * @return a new {@link Compressor} instance for the given compression algorithm * @throws IllegalArgumentException if the compression type is unknown */ public static Compressor createCompressor(String compression) throws IllegalArgumentException { if (!CompressionType.isValidCompressionType(compression)) { throw new IllegalArgumentException("Unkonwn compression type " + compression); } return createCompressor(CompressionType.fromString(compression)); }
/** * Creates a new {@link Compressor} for the given {@link FileType}. * * @param fileType the file type to create the compressor for * @return a new Compressor instance * @throws IllegalArgumentException if the given file type is not a known compression type */ public static Compressor createCompressor(FileType fileType) throws IllegalArgumentException { if (fileType == FileType.UNKNOWN) { throw new IllegalArgumentException("Unknown file type"); } if (fileType.isCompressed()) { return createCompressor(fileType.getCompressionType()); } else { throw new IllegalArgumentException("Unknown compressed file type " + fileType); } }