1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 package org.eclipse.jgit.archive;
44
45 import java.io.IOException;
46 import java.io.OutputStream;
47 import java.util.Arrays;
48 import java.util.Collections;
49 import java.util.List;
50 import java.util.Map;
51
52 import org.apache.commons.compress.archivers.ArchiveOutputStream;
53 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
54 import org.eclipse.jgit.api.ArchiveCommand;
55 import org.eclipse.jgit.lib.FileMode;
56 import org.eclipse.jgit.lib.ObjectId;
57 import org.eclipse.jgit.lib.ObjectLoader;
58
59
60
61
62 public final class TgzFormat extends BaseFormat implements
63 ArchiveCommand.Format<ArchiveOutputStream> {
64 private static final List<String> SUFFIXES = Collections
65 .unmodifiableList(Arrays.asList(".tar.gz", ".tgz"));
66
67 private final ArchiveCommand.Format<ArchiveOutputStream> tarFormat = new TarFormat();
68
69 @Override
70 public ArchiveOutputStream createArchiveOutputStream(OutputStream s)
71 throws IOException {
72 return createArchiveOutputStream(s,
73 Collections.<String, Object> emptyMap());
74 }
75
76
77
78
79 @Override
80 public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
81 Map<String, Object> o) throws IOException {
82 GzipCompressorOutputStream out = new GzipCompressorOutputStream(s);
83 return tarFormat.createArchiveOutputStream(out, o);
84 }
85
86 @Deprecated
87 @Override
88 public void putEntry(ArchiveOutputStream out,
89 String path, FileMode mode, ObjectLoader loader)
90 throws IOException {
91 putEntry(out, null, path, mode,loader);
92 }
93
94
95
96
97 @Override
98 public void putEntry(ArchiveOutputStream out,
99 ObjectId tree, String path, FileMode mode, ObjectLoader loader)
100 throws IOException {
101 tarFormat.putEntry(out, tree, path, mode, loader);
102 }
103
104 @Override
105 public Iterable<String> suffixes() {
106 return SUFFIXES;
107 }
108
109 @Override
110 public boolean equals(Object other) {
111 return (other instanceof TgzFormat);
112 }
113
114 @Override
115 public int hashCode() {
116 return getClass().hashCode();
117 }
118 }