6 Commits
dev ... v0.0.3

Author SHA1 Message Date
279289fb22 Merge pull request 'v0.0.3' (#6) from dev into master
Reviewed-on: #6
2026-04-02 08:26:38 +00:00
913b9b5328 Merge pull request 'v0.0.2' (#5) from dev into master
Reviewed-on: #5
2026-04-01 14:52:04 +00:00
88b1fd6e02 Merge pull request 'v0.0.1' (#4) from dev into master
Reviewed-on: #4
2026-04-01 07:23:36 +00:00
1f13cdd7bc Merge pull request 'v0.0.1' (#3) from dev into master
Reviewed-on: #3
2026-04-01 07:20:16 +00:00
0b078278f0 Merge pull request 'v0.0.1' (#2) from dev into master
Reviewed-on: #2
2026-04-01 07:13:48 +00:00
c0b2ae11a7 Merge pull request 'v0.0.1' (#1) from dev into master
Reviewed-on: #1
2026-04-01 06:09:52 +00:00
16 changed files with 97 additions and 103 deletions

View File

@@ -6,7 +6,7 @@
<groupId>com.imyeyu.compress</groupId> <groupId>com.imyeyu.compress</groupId>
<artifactId>timi-compress</artifactId> <artifactId>timi-compress</artifactId>
<version>0.0.4</version> <version>0.0.3</version>
<properties> <properties>
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>

View File

@@ -58,8 +58,8 @@ public enum CompressType {
* @return 压缩操作对象 * @return 压缩操作对象
* @throws Exception 实例化失败 * @throws Exception 实例化失败
*/ */
public Compressor<?> compressFrom(String fromPath) throws Exception { public Compressor<?> ofCompress(String fromPath) throws Exception {
return getCompressor().of(fromPath); return getCompressor().from(fromPath);
} }
/** /**
@@ -69,8 +69,8 @@ public enum CompressType {
* @return 压缩操作对象 * @return 压缩操作对象
* @throws Exception 实例化失败 * @throws Exception 实例化失败
*/ */
public Compressor<?> compressFrom(File fromFile) throws Exception { public Compressor<?> ofCompress(File fromFile) throws Exception {
return getCompressor().of(fromFile); return getCompressor().from(fromFile);
} }
/** /**
@@ -90,8 +90,8 @@ public enum CompressType {
* @return 解压操作对象 * @return 解压操作对象
* @throws Exception 实例化失败 * @throws Exception 实例化失败
*/ */
public Decompressor<?> decompressedFrom(File fromFile) throws Exception { public Decompressor<?> ofCompressed(File fromFile) throws Exception {
return getDecompressor().of(fromFile); return getDecompressor().from(fromFile);
} }
/** /**
@@ -101,8 +101,8 @@ public enum CompressType {
* @return 解压操作对象 * @return 解压操作对象
* @throws Exception 实例化失败 * @throws Exception 实例化失败
*/ */
public Decompressor<?> decompressedFrom(InputStream fromStream) throws Exception { public Decompressor<?> ofCompressed(InputStream fromStream) throws Exception {
return getDecompressor().of(fromStream); return getDecompressor().from(fromStream);
} }
/** /**
@@ -114,7 +114,7 @@ public enum CompressType {
* @throws UnsupportedOperationException 不支持的文件 * @throws UnsupportedOperationException 不支持的文件
* @throws Exception 实例化失败 * @throws Exception 实例化失败
*/ */
public static Decompressor<?> from(File file) throws Exception { public static Decompressor<?> fromFile(File file) throws Exception {
try (InputStream inputStream = IO.getInputStream(file)) { try (InputStream inputStream = IO.getInputStream(file)) {
byte[] head = new byte[512]; byte[] head = new byte[512];
int length = inputStream.read(head); int length = inputStream.read(head);
@@ -122,16 +122,16 @@ public enum CompressType {
throw new UnsupportedOperationException("empty file"); throw new UnsupportedOperationException("empty file");
} }
if (SevenZFile.matches(head, length)) { if (SevenZFile.matches(head, length)) {
return Z7.decompressedFrom(file); return Z7.ofCompressed(file);
} }
if (ZipArchiveInputStream.matches(head, length)) { if (ZipArchiveInputStream.matches(head, length)) {
return ZIP.decompressedFrom(file); return ZIP.ofCompressed(file);
} }
if (GzipCompressorInputStream.matches(head, length)) { if (GzipCompressorInputStream.matches(head, length)) {
return GZIP.decompressedFrom(file); return GZIP.ofCompressed(file);
} }
if (TarArchiveInputStream.matches(head, length)) { if (TarArchiveInputStream.matches(head, length)) {
return TAR.decompressedFrom(file); return TAR.ofCompressed(file);
} }
} }
throw new UnsupportedOperationException("not support file"); throw new UnsupportedOperationException("not support file");

View File

@@ -24,7 +24,7 @@ public abstract class Compressor<T extends Compressor<T>> extends AbstractRunner
* @param fromPath 源路径 * @param fromPath 源路径
* @return 当前压缩器 * @return 当前压缩器
*/ */
protected T of(String fromPath) { public T from(String fromPath) {
TimiException.required(fromPath, "not found fromPath"); TimiException.required(fromPath, "not found fromPath");
this.fromPath = fromPath; this.fromPath = fromPath;
return self(); return self();
@@ -36,9 +36,9 @@ public abstract class Compressor<T extends Compressor<T>> extends AbstractRunner
* @param fromFile 源文件 * @param fromFile 源文件
* @return 当前压缩器 * @return 当前压缩器
*/ */
protected T of(File fromFile) { public T from(File fromFile) {
TimiException.required(fromFile, "not found fromFile"); TimiException.required(fromFile, "not found fromFile");
return of(fromFile.getAbsolutePath()); return from(fromFile.getAbsolutePath());
} }
/** /**

View File

@@ -27,7 +27,7 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
* @param fromFile 源压缩文件 * @param fromFile 源压缩文件
* @return 当前解压器 * @return 当前解压器
*/ */
protected T of(File fromFile) { public T from(File fromFile) {
TimiException.required(fromFile, "not found fromFile"); TimiException.required(fromFile, "not found fromFile");
this.fromFile = fromFile; this.fromFile = fromFile;
this.fromStream = null; this.fromStream = null;
@@ -40,9 +40,9 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
* @param fromPath 源压缩文件路径 * @param fromPath 源压缩文件路径
* @return 当前解压器 * @return 当前解压器
*/ */
protected T of(String fromPath) { public T from(String fromPath) {
TimiException.required(fromPath, "not found fromPath"); TimiException.required(fromPath, "not found fromPath");
return of(new File(fromPath)); return from(new File(fromPath));
} }
/** /**
@@ -51,7 +51,7 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
* @param fromStream 源压缩输入流 * @param fromStream 源压缩输入流
* @return 当前解压器 * @return 当前解压器
*/ */
public T of(InputStream fromStream) { public T from(InputStream fromStream) {
TimiException.required(fromStream, "not found fromStream"); TimiException.required(fromStream, "not found fromStream");
this.fromStream = fromStream; this.fromStream = fromStream;
this.fromFile = null; this.fromFile = null;

View File

@@ -26,8 +26,8 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
* @param fromPath 源路径 * @param fromPath 源路径
* @return 压缩器 * @return 压缩器
*/ */
public static GZipCompressor from(String fromPath) { public static GZipCompressor of(String fromPath) {
return new GZipCompressor().of(fromPath); return new GZipCompressor().from(fromPath);
} }
/** /**
@@ -36,8 +36,8 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
* @param fromFile 源文件 * @param fromFile 源文件
* @return 压缩器 * @return 压缩器
*/ */
public static GZipCompressor from(File fromFile) { public static GZipCompressor of(File fromFile) {
return new GZipCompressor().of(fromFile); return new GZipCompressor().from(fromFile);
} }
@Override @Override
@@ -46,10 +46,10 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
List<File> files = IO.listFile(fromFile); List<File> files = IO.listFile(fromFile);
String basePath = files.getFirst().getParentFile().getAbsolutePath(); String basePath = files.getFirst().getParentFile().getAbsolutePath();
initByteProgress(IO.calcSize(fromFile)); initByteProgress(IO.calcSize(fromFile));
try (
GzipCompressorOutputStream gzipOutputStream = new GzipCompressorOutputStream(new BufferedOutputStream(nonClosing(toStream))); GzipCompressorOutputStream gzipOutputStream = new GzipCompressorOutputStream(new BufferedOutputStream(nonClosing(toStream)));
TarArchiveOutputStream tarOutputStream = null; TarArchiveOutputStream tarOutputStream = new TarArchiveOutputStream(gzipOutputStream)
try { ) {
tarOutputStream = new TarArchiveOutputStream(gzipOutputStream);
for (File sourceFile : files) { for (File sourceFile : files) {
String name = sourceFile.getAbsolutePath().substring(basePath.length() + 1); String name = sourceFile.getAbsolutePath().substring(basePath.length() + 1);
TarArchiveEntry tarEntry = new TarArchiveEntry(sourceFile, normalizeEntryName(name)); TarArchiveEntry tarEntry = new TarArchiveEntry(sourceFile, normalizeEntryName(name));
@@ -61,13 +61,9 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
handleFile(sourceFile); handleFile(sourceFile);
} }
tarOutputStream.finish(); tarOutputStream.finish();
gzipOutputStream.finish();
finishProgress(); finishProgress();
} finally { } finally {
if (tarOutputStream != null) {
tarOutputStream.close();
} else {
gzipOutputStream.close();
}
resetProgress(); resetProgress();
} }
} }

View File

@@ -23,8 +23,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
* @param fromFile 源压缩文件 * @param fromFile 源压缩文件
* @return 解压器 * @return 解压器
*/ */
public static GZipDecompressor from(File fromFile) { public static GZipDecompressor of(File fromFile) {
return new GZipDecompressor().of(fromFile); return new GZipDecompressor().from(fromFile);
} }
/** /**
@@ -33,8 +33,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
* @param fromPath 源压缩文件路径 * @param fromPath 源压缩文件路径
* @return 解压器 * @return 解压器
*/ */
public static GZipDecompressor from(String fromPath) { public static GZipDecompressor of(String fromPath) {
return new GZipDecompressor().of(fromPath); return new GZipDecompressor().from(fromPath);
} }
/** /**
@@ -43,8 +43,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
* @param fromStream 源压缩输入流 * @param fromStream 源压缩输入流
* @return 解压器 * @return 解压器
*/ */
public static GZipDecompressor from(InputStream fromStream) { public static GZipDecompressor of(InputStream fromStream) {
return new GZipDecompressor().of(fromStream); return new GZipDecompressor().from(fromStream);
} }
@Override @Override

View File

@@ -24,8 +24,8 @@ public class TarCompressor extends Compressor<TarCompressor> {
* @param fromPath 源路径 * @param fromPath 源路径
* @return 压缩器 * @return 压缩器
*/ */
public static TarCompressor from(String fromPath) { public static TarCompressor of(String fromPath) {
return new TarCompressor().of(fromPath); return new TarCompressor().from(fromPath);
} }
/** /**
@@ -34,8 +34,8 @@ public class TarCompressor extends Compressor<TarCompressor> {
* @param fromFile 源文件 * @param fromFile 源文件
* @return 压缩器 * @return 压缩器
*/ */
public static TarCompressor from(File fromFile) { public static TarCompressor of(File fromFile) {
return new TarCompressor().of(fromFile); return new TarCompressor().from(fromFile);
} }
@Override @Override

View File

@@ -22,8 +22,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
* @param fromFile 源压缩文件 * @param fromFile 源压缩文件
* @return 解压器 * @return 解压器
*/ */
public static TarDecompressor from(File fromFile) { public static TarDecompressor of(File fromFile) {
return new TarDecompressor().of(fromFile); return new TarDecompressor().from(fromFile);
} }
/** /**
@@ -32,8 +32,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
* @param fromPath 源压缩文件路径 * @param fromPath 源压缩文件路径
* @return 解压器 * @return 解压器
*/ */
public static TarDecompressor from(String fromPath) { public static TarDecompressor of(String fromPath) {
return new TarDecompressor().of(fromPath); return new TarDecompressor().from(fromPath);
} }
/** /**
@@ -42,8 +42,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
* @param fromStream 源压缩输入流 * @param fromStream 源压缩输入流
* @return 解压器 * @return 解压器
*/ */
public static TarDecompressor from(InputStream fromStream) { public static TarDecompressor of(InputStream fromStream) {
return new TarDecompressor().of(fromStream); return new TarDecompressor().from(fromStream);
} }
@Override @Override

View File

@@ -25,8 +25,8 @@ public class Z7Compressor extends Compressor<Z7Compressor> {
* @param fromPath 源路径 * @param fromPath 源路径
* @return 压缩器 * @return 压缩器
*/ */
public static Z7Compressor from(String fromPath) { public static Z7Compressor of(String fromPath) {
return new Z7Compressor().of(fromPath); return new Z7Compressor().from(fromPath);
} }
/** /**
@@ -35,15 +35,15 @@ public class Z7Compressor extends Compressor<Z7Compressor> {
* @param fromFile 源文件 * @param fromFile 源文件
* @return 压缩器 * @return 压缩器
*/ */
public static Z7Compressor from(File fromFile) { public static Z7Compressor of(File fromFile) {
return new Z7Compressor().of(fromFile); return new Z7Compressor().from(fromFile);
} }
@Override @Override
protected void toStream(String fromPath, OutputStream toStream) throws Exception { protected void toStream(String fromPath, OutputStream toStream) throws Exception {
Path tempFile = Files.createTempFile("timi-compress-", ".7z"); Path tempFile = Files.createTempFile("timi-compress-", ".7z");
try { try {
of(fromPath).toFile(tempFile.toFile()); from(fromPath).toFile(tempFile.toFile());
try (InputStream inputStream = Files.newInputStream(tempFile)) { try (InputStream inputStream = Files.newInputStream(tempFile)) {
transfer(inputStream, toStream, false); transfer(inputStream, toStream, false);
toStream.flush(); toStream.flush();

View File

@@ -24,8 +24,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
* @param fromFile 源压缩文件 * @param fromFile 源压缩文件
* @return 解压器 * @return 解压器
*/ */
public static Z7Decompressor from(File fromFile) { public static Z7Decompressor of(File fromFile) {
return new Z7Decompressor().of(fromFile); return new Z7Decompressor().from(fromFile);
} }
/** /**
@@ -34,8 +34,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
* @param fromPath 源压缩文件路径 * @param fromPath 源压缩文件路径
* @return 解压器 * @return 解压器
*/ */
public static Z7Decompressor from(String fromPath) { public static Z7Decompressor of(String fromPath) {
return new Z7Decompressor().of(fromPath); return new Z7Decompressor().from(fromPath);
} }
/** /**
@@ -44,8 +44,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
* @param fromStream 源压缩输入流 * @param fromStream 源压缩输入流
* @return 解压器 * @return 解压器
*/ */
public static Z7Decompressor from(InputStream fromStream) { public static Z7Decompressor of(InputStream fromStream) {
return new Z7Decompressor().of(fromStream); return new Z7Decompressor().from(fromStream);
} }
@Override @Override

View File

@@ -24,8 +24,8 @@ public class ZipCompressor extends Compressor<ZipCompressor> {
* @param fromPath 源路径 * @param fromPath 源路径
* @return 压缩器 * @return 压缩器
*/ */
public static ZipCompressor from(String fromPath) { public static ZipCompressor of(String fromPath) {
return new ZipCompressor().of(fromPath); return new ZipCompressor().from(fromPath);
} }
/** /**
@@ -34,8 +34,8 @@ public class ZipCompressor extends Compressor<ZipCompressor> {
* @param fromFile 源文件 * @param fromFile 源文件
* @return 压缩器 * @return 压缩器
*/ */
public static ZipCompressor from(File fromFile) { public static ZipCompressor of(File fromFile) {
return new ZipCompressor().of(fromFile); return new ZipCompressor().from(fromFile);
} }
@Override @Override

View File

@@ -24,8 +24,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
* @param fromFile 源压缩文件 * @param fromFile 源压缩文件
* @return 解压器 * @return 解压器
*/ */
public static ZipDecompressor from(File fromFile) { public static ZipDecompressor of(File fromFile) {
return new ZipDecompressor().of(fromFile); return new ZipDecompressor().from(fromFile);
} }
/** /**
@@ -34,8 +34,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
* @param fromPath 源压缩文件路径 * @param fromPath 源压缩文件路径
* @return 解压器 * @return 解压器
*/ */
public static ZipDecompressor from(String fromPath) { public static ZipDecompressor of(String fromPath) {
return new ZipDecompressor().of(fromPath); return new ZipDecompressor().from(fromPath);
} }
/** /**
@@ -44,8 +44,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
* @param fromStream 源压缩输入流 * @param fromStream 源压缩输入流
* @return 解压器 * @return 解压器
*/ */
public static ZipDecompressor from(InputStream fromStream) { public static ZipDecompressor of(InputStream fromStream) {
return new ZipDecompressor().of(fromStream); return new ZipDecompressor().from(fromStream);
} }
@Override @Override

View File

@@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@@ -22,7 +21,7 @@ public class GzipTest {
@Test @Test
public void testStaticCompress() throws Exception { public void testStaticCompress() throws Exception {
GZipCompressor compressor = GZipCompressor.from("testSrc").toFile("testOut/test.gz"); GZipCompressor compressor = GZipCompressor.of("testSrc").toFile("testOut/test.gz");
Assertions.assertNotNull(compressor); Assertions.assertNotNull(compressor);
} }
@@ -31,7 +30,7 @@ public class GzipTest {
File out = IO.file("testOut/test-chain.gz"); File out = IO.file("testOut/test-chain.gz");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
GZipCompressor compressor = GZipCompressor.from("testSrc"); GZipCompressor compressor = GZipCompressor.of("testSrc");
Assertions.assertSame( Assertions.assertSame(
compressor, compressor,
compressor compressor
@@ -46,15 +45,15 @@ public class GzipTest {
@Test @Test
public void testDecompress() throws Exception { public void testDecompress() throws Exception {
File in = IO.file("testOut/test.gz"); File in = IO.file("testOut/test.gz");
GZipCompressor.from("testSrc").toFile(in); GZipCompressor.of("testSrc").toFile(in);
File out = IO.dir("testOutDe"); File out = IO.dir("testOutDe");
CompressType.from(in).toPath(out.getAbsolutePath()); CompressType.fromFile(in).toPath(out.getAbsolutePath());
} }
@Test @Test
public void testCompressToStream() throws Exception { public void testCompressToStream() throws Exception {
try (OutputStream os = IO.getOutputStream(IO.file("testOut/test.tar.gz"))) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.GZIP.compressFrom("testSrc").toStream(os); CompressType.GZIP.ofCompress("testSrc").toStream(outputStream);
} }
} }
@@ -62,13 +61,13 @@ public class GzipTest {
public void testChainDecompressFromStream() throws Exception { public void testChainDecompressFromStream() throws Exception {
byte[] bytes; byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.GZIP.compressFrom("testSrc").toStream(outputStream); CompressType.GZIP.ofCompress("testSrc").toStream(outputStream);
bytes = outputStream.toByteArray(); bytes = outputStream.toByteArray();
} }
File out = IO.dir("testOutDeStream/gzip"); File out = IO.dir("testOutDeStream/gzip");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
GZipDecompressor decompressor = GZipDecompressor.from(new ByteArrayInputStream(bytes)); GZipDecompressor decompressor = GZipDecompressor.of(new ByteArrayInputStream(bytes));
Assertions.assertSame( Assertions.assertSame(
decompressor, decompressor,
decompressor decompressor

View File

@@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@@ -22,7 +21,7 @@ public class TarTest {
@Test @Test
public void testStaticCompress() throws Exception { public void testStaticCompress() throws Exception {
TarCompressor compressor = TarCompressor.from("testSrc").toFile("testOut/test.tar"); TarCompressor compressor = TarCompressor.of("testSrc").toFile("testOut/test.tar");
Assertions.assertNotNull(compressor); Assertions.assertNotNull(compressor);
} }
@@ -31,7 +30,7 @@ public class TarTest {
File out = IO.file("testOut/test-chain.tar"); File out = IO.file("testOut/test-chain.tar");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
TarCompressor compressor = TarCompressor.from("testSrc"); TarCompressor compressor = TarCompressor.of("testSrc");
Assertions.assertSame( Assertions.assertSame(
compressor, compressor,
compressor compressor
@@ -46,15 +45,15 @@ public class TarTest {
@Test @Test
public void testDecompress() throws Exception { public void testDecompress() throws Exception {
File in = IO.file("testOut/test.tar"); File in = IO.file("testOut/test.tar");
TarCompressor.from("testSrc").toFile(in); TarCompressor.of("testSrc").toFile(in);
File out = IO.dir("testOutDe"); File out = IO.dir("testOutDe");
CompressType.from(in).toPath(out.getAbsolutePath()); CompressType.fromFile(in).toPath(out.getAbsolutePath());
} }
@Test @Test
public void testCompressToStream() throws Exception { public void testCompressToStream() throws Exception {
try (OutputStream os = IO.getOutputStream(IO.file("testOut/test.tar"))) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.TAR.compressFrom("testSrc").toStream(os); CompressType.TAR.ofCompress("testSrc").toStream(outputStream);
} }
} }
@@ -62,13 +61,13 @@ public class TarTest {
public void testChainDecompressFromStream() throws Exception { public void testChainDecompressFromStream() throws Exception {
byte[] bytes; byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.TAR.compressFrom("testSrc").toStream(outputStream); CompressType.TAR.ofCompress("testSrc").toStream(outputStream);
bytes = outputStream.toByteArray(); bytes = outputStream.toByteArray();
} }
File out = IO.dir("testOutDeStream/tar"); File out = IO.dir("testOutDeStream/tar");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
TarDecompressor decompressor = TarDecompressor.from(new ByteArrayInputStream(bytes)); TarDecompressor decompressor = TarDecompressor.of(new ByteArrayInputStream(bytes));
Assertions.assertSame( Assertions.assertSame(
decompressor, decompressor,
decompressor decompressor

View File

@@ -21,7 +21,7 @@ public class Z7Test {
@Test @Test
public void testStaticCompress() throws Exception { public void testStaticCompress() throws Exception {
Z7Compressor compressor = Z7Compressor.from("testSrc").toFile("testOut/test.7z"); Z7Compressor compressor = Z7Compressor.of("testSrc").toFile("testOut/test.7z");
Assertions.assertNotNull(compressor); Assertions.assertNotNull(compressor);
} }
@@ -30,7 +30,7 @@ public class Z7Test {
File out = IO.file("testOut/test-chain.7z"); File out = IO.file("testOut/test-chain.7z");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
Z7Compressor compressor = Z7Compressor.from("testSrc"); Z7Compressor compressor = Z7Compressor.of("testSrc");
Assertions.assertSame( Assertions.assertSame(
compressor, compressor,
compressor compressor
@@ -45,15 +45,15 @@ public class Z7Test {
@Test @Test
public void testDecompress() throws Exception { public void testDecompress() throws Exception {
File in = IO.file("testOut/test.7z"); File in = IO.file("testOut/test.7z");
Z7Compressor.from("testSrc").toFile(in); Z7Compressor.of("testSrc").toFile(in);
File out = IO.dir("testOutDe"); File out = IO.dir("testOutDe");
CompressType.from(in).toPath(out.getAbsolutePath()); CompressType.fromFile(in).toPath(out.getAbsolutePath());
} }
@Test @Test
public void testCompressToStream() throws Exception { public void testCompressToStream() throws Exception {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.Z7.compressFrom("testSrc").toStream(outputStream); CompressType.Z7.ofCompress("testSrc").toStream(outputStream);
} }
} }
@@ -61,13 +61,13 @@ public class Z7Test {
public void testChainDecompressFromStream() throws Exception { public void testChainDecompressFromStream() throws Exception {
byte[] bytes; byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.Z7.compressFrom("testSrc").toStream(outputStream); CompressType.Z7.ofCompress("testSrc").toStream(outputStream);
bytes = outputStream.toByteArray(); bytes = outputStream.toByteArray();
} }
File out = IO.dir("testOutDeStream/z7"); File out = IO.dir("testOutDeStream/z7");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
Z7Decompressor decompressor = Z7Decompressor.from(new ByteArrayInputStream(bytes)); Z7Decompressor decompressor = Z7Decompressor.of(new ByteArrayInputStream(bytes));
Assertions.assertSame( Assertions.assertSame(
decompressor, decompressor,
decompressor decompressor

View File

@@ -21,7 +21,7 @@ public class ZipTest {
@Test @Test
public void testStaticCompress() throws Exception { public void testStaticCompress() throws Exception {
ZipCompressor compressor = ZipCompressor.from("testSrc").toFile("testOut/test.zip"); ZipCompressor compressor = ZipCompressor.of("testSrc").toFile("testOut/test.zip");
Assertions.assertNotNull(compressor); Assertions.assertNotNull(compressor);
} }
@@ -30,7 +30,7 @@ public class ZipTest {
File out = IO.file("testOut/test-chain.zip"); File out = IO.file("testOut/test-chain.zip");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
ZipCompressor compressor = ZipCompressor.from("testSrc"); ZipCompressor compressor = ZipCompressor.of("testSrc");
Assertions.assertSame( Assertions.assertSame(
compressor, compressor,
compressor compressor
@@ -45,15 +45,15 @@ public class ZipTest {
@Test @Test
public void testDecompress() throws Exception { public void testDecompress() throws Exception {
File in = IO.file("testOut/test.zip"); File in = IO.file("testOut/test.zip");
ZipCompressor.from("testSrc").toFile(in); ZipCompressor.of("testSrc").toFile(in);
File out = IO.dir("testOutDe"); File out = IO.dir("testOutDe");
CompressType.from(in).toPath(out.getAbsolutePath()); CompressType.fromFile(in).toPath(out.getAbsolutePath());
} }
@Test @Test
public void testCompressToStream() throws Exception { public void testCompressToStream() throws Exception {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.ZIP.compressFrom("testSrc").toStream(outputStream); CompressType.ZIP.ofCompress("testSrc").toStream(outputStream);
} }
} }
@@ -61,13 +61,13 @@ public class ZipTest {
public void testChainDecompressFromStream() throws Exception { public void testChainDecompressFromStream() throws Exception {
byte[] bytes; byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
CompressType.ZIP.compressFrom("testSrc").toStream(outputStream); CompressType.ZIP.ofCompress("testSrc").toStream(outputStream);
bytes = outputStream.toByteArray(); bytes = outputStream.toByteArray();
} }
File out = IO.dir("testOutDeStream/zip"); File out = IO.dir("testOutDeStream/zip");
AtomicInteger fileCount = new AtomicInteger(); AtomicInteger fileCount = new AtomicInteger();
AtomicReference<Double> progress = new AtomicReference<>(0D); AtomicReference<Double> progress = new AtomicReference<>(0D);
ZipDecompressor decompressor = ZipDecompressor.from(new ByteArrayInputStream(bytes)); ZipDecompressor decompressor = ZipDecompressor.of(new ByteArrayInputStream(bytes));
Assertions.assertSame( Assertions.assertSame(
decompressor, decompressor,
decompressor decompressor