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.xz.XZCompressorOutputStream;
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 TxzFormat extends BaseFormat implements
63 ArchiveCommand.Format<ArchiveOutputStream> {
64 private static final List<String> SUFFIXES = Collections
65 .unmodifiableList(Arrays.asList(".tar.xz", ".txz"));
66
67 private final ArchiveCommand.Format<ArchiveOutputStream> tarFormat = new TarFormat();
68
69
70 @Override
71 public ArchiveOutputStream createArchiveOutputStream(OutputStream s)
72 throws IOException {
73 return createArchiveOutputStream(s,
74 Collections.<String, Object> emptyMap());
75 }
76
77
78 @Override
79 public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
80 Map<String, Object> o) throws IOException {
81 XZCompressorOutputStream out = new XZCompressorOutputStream(s);
82 return tarFormat.createArchiveOutputStream(out, o);
83 }
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 @Override
96 public void putEntry(ArchiveOutputStream out,
97 ObjectId tree, String path, FileMode mode, ObjectLoader loader)
98 throws IOException {
99 tarFormat.putEntry(out, tree, path, mode, loader);
100 }
101
102
103 @Override
104 public Iterable<String> suffixes() {
105 return SUFFIXES;
106 }
107
108
109 @Override
110 public boolean equals(Object other) {
111 return (other instanceof TxzFormat);
112 }
113
114
115 @Override
116 public int hashCode() {
117 return getClass().hashCode();
118 }
119 }