1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.archive;
11
12 import java.io.IOException;
13 import java.io.OutputStream;
14 import java.util.Arrays;
15 import java.util.Collections;
16 import java.util.List;
17 import java.util.Map;
18
19 import org.apache.commons.compress.archivers.ArchiveOutputStream;
20 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
21 import org.eclipse.jgit.api.ArchiveCommand;
22 import org.eclipse.jgit.lib.FileMode;
23 import org.eclipse.jgit.lib.ObjectId;
24 import org.eclipse.jgit.lib.ObjectLoader;
25
26
27
28
29 public final class TgzFormat extends BaseFormat implements
30 ArchiveCommand.Format<ArchiveOutputStream> {
31 private static final List<String> SUFFIXES = Collections
32 .unmodifiableList(Arrays.asList(".tar.gz", ".tgz"));
33
34 private final ArchiveCommand.Format<ArchiveOutputStream> tarFormat = new TarFormat();
35
36
37 @Override
38 public ArchiveOutputStream createArchiveOutputStream(OutputStream s)
39 throws IOException {
40 return createArchiveOutputStream(s,
41 Collections.<String, Object> emptyMap());
42 }
43
44
45 @Override
46 public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
47 Map<String, Object> o) throws IOException {
48 GzipCompressorOutputStream out = new GzipCompressorOutputStream(s);
49 return tarFormat.createArchiveOutputStream(out, o);
50 }
51
52
53 @Override
54 public void putEntry(ArchiveOutputStream out,
55 ObjectId tree, String path, FileMode mode, ObjectLoader loader)
56 throws IOException {
57 tarFormat.putEntry(out, tree, path, mode, loader);
58 }
59
60
61 @Override
62 public Iterable<String> suffixes() {
63 return SUFFIXES;
64 }
65
66
67 @Override
68 public boolean equals(Object other) {
69 return (other instanceof TgzFormat);
70 }
71
72
73 @Override
74 public int hashCode() {
75 return getClass().hashCode();
76 }
77 }