/** * Creates an Archiver for the given archive format. * * @param archiveFormat the archive format e.g. "tar" or "zip" * @return a new Archiver instance * @throws IllegalArgumentException if the archive format is unknown */ public static Archiver createArchiver(String archiveFormat) throws IllegalArgumentException { if (!ArchiveFormat.isValidArchiveFormat(archiveFormat)) { throw new IllegalArgumentException("Unknown archive format " + archiveFormat); } return createArchiver(ArchiveFormat.fromString(archiveFormat)); }
/** * Checks if the given archive format name is valid and known format. * * @param archiveFormat the archive format name * @return true if the given archive format is known to the factory, false otherwise */ public static boolean isValidArchiveFormat(String archiveFormat) { for (ArchiveFormat format : values()) { if (archiveFormat.trim().equalsIgnoreCase(format.getName())) { return true; } } return false; }
static ArchiveOutputStream createArchiveOutputStream(ArchiveFormat format, File archive) throws IOException, ArchiveException { return createArchiveOutputStream(format.getName(), new FileOutputStream(archive)); }
@Override public String getFilenameExtension() { return getArchiveFormat().getDefaultFileExtension(); }
/** * @see {@link ArchiveStreamFactory#createArchiveInputStream(String, InputStream)} */ static ArchiveInputStream createArchiveInputStream(ArchiveFormat archiveFormat, InputStream in) throws ArchiveException { return createArchiveInputStream(archiveFormat.getName(), in); }
@Override public String getFilenameExtension() { return getArchiveFormat().getDefaultFileExtension(); }
/** * Checks if the given archive format name is valid and known format. * * @param archiveFormat the archive format name * @return true if the given archive format is known to the factory, false otherwise */ public static boolean isValidArchiveFormat(String archiveFormat) { for (ArchiveFormat format : values()) { if (archiveFormat.trim().equalsIgnoreCase(format.getName())) { return true; } } return false; }
/** * Creates an Archiver for the given archive format. * * @param archiveFormat the archive format e.g. "tar" or "zip" * @return a new Archiver instance * @throws IllegalArgumentException if the archive format is unknown */ public static Archiver createArchiver(String archiveFormat) throws IllegalArgumentException { if (!ArchiveFormat.isValidArchiveFormat(archiveFormat)) { throw new IllegalArgumentException("Unknown archive format " + archiveFormat); } return createArchiver(ArchiveFormat.fromString(archiveFormat)); }
/** * @see {@link ArchiveStreamFactory#createArchiveInputStream(String, InputStream)} */ static ArchiveInputStream createArchiveInputStream(ArchiveFormat archiveFormat, InputStream in) throws ArchiveException { return createArchiveInputStream(archiveFormat.getName(), in); }
/** * Attempts to return the {@link ArchiveFormat} instance from a possible given string representation. Ignores case. * * @param archiveFormat string representation of the archive format. E.g. "tar" or "ZIP". * @return the compression type enum * @throws IllegalArgumentException if the given archive format is unknown. */ public static ArchiveFormat fromString(String archiveFormat) { for (ArchiveFormat format : values()) { if (archiveFormat.trim().equalsIgnoreCase(format.getName())) { return format; } } throw new IllegalArgumentException("Unknown archive format " + archiveFormat); }
/** * Creates an Archiver for the given archive format that uses compression. * * @param archiveFormat the archive format e.g. "tar" or "zip" * @param compression the compression algorithm name e.g. "gz" * @return a new Archiver instance that also handles compression * @throws IllegalArgumentException if the archive format or the compression type is unknown */ public static Archiver createArchiver(String archiveFormat, String compression) throws IllegalArgumentException { if (!ArchiveFormat.isValidArchiveFormat(archiveFormat)) { throw new IllegalArgumentException("Unknown archive format " + archiveFormat); } if (!CompressionType.isValidCompressionType(compression)) { throw new IllegalArgumentException("Unknown compression type " + compression); } return createArchiver(ArchiveFormat.fromString(archiveFormat), CompressionType.fromString(compression)); }
static ArchiveOutputStream createArchiveOutputStream(ArchiveFormat format, File archive) throws IOException, ArchiveException { return createArchiveOutputStream(format.getName(), new FileOutputStream(archive)); }
/** * Attempts to return the {@link ArchiveFormat} instance from a possible given string representation. Ignores case. * * @param archiveFormat string representation of the archive format. E.g. "tar" or "ZIP". * @return the compression type enum * @throws IllegalArgumentException if the given archive format is unknown. */ public static ArchiveFormat fromString(String archiveFormat) { for (ArchiveFormat format : values()) { if (archiveFormat.trim().equalsIgnoreCase(format.getName())) { return format; } } throw new IllegalArgumentException("Unknown archive format " + archiveFormat); }
/** * Creates an Archiver for the given archive format that uses compression. * * @param archiveFormat the archive format e.g. "tar" or "zip" * @param compression the compression algorithm name e.g. "gz" * @return a new Archiver instance that also handles compression * @throws IllegalArgumentException if the archive format or the compression type is unknown */ public static Archiver createArchiver(String archiveFormat, String compression) throws IllegalArgumentException { if (!ArchiveFormat.isValidArchiveFormat(archiveFormat)) { throw new IllegalArgumentException("Unknown archive format " + archiveFormat); } if (!CompressionType.isValidCompressionType(compression)) { throw new IllegalArgumentException("Unknown compression type " + compression); } return createArchiver(ArchiveFormat.fromString(archiveFormat), CompressionType.fromString(compression)); }