1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.compress.archivers.dump;
20
21 import java.io.IOException;
22 import java.util.Date;
23 import java.util.Objects;
24
25 import org.apache.commons.compress.archivers.zip.ZipEncoding;
26
27
28
29
30
31
32
33
34 public class DumpArchiveSummary {
35
36 private long dumpDate;
37 private long previousDumpDate;
38 private int volume;
39 private String label;
40 private int level;
41 private String filesys;
42 private String devname;
43 private String hostname;
44 private int flags;
45 private int firstrec;
46 private int ntrec;
47
48 DumpArchiveSummary(final byte[] buffer, final ZipEncoding encoding) throws IOException {
49 dumpDate = 1000L * DumpArchiveUtil.convert32(buffer, 4);
50 previousDumpDate = 1000L * DumpArchiveUtil.convert32(buffer, 8);
51 volume = DumpArchiveUtil.convert32(buffer, 12);
52 label = DumpArchiveUtil.decode(encoding, buffer, 676, DumpArchiveConstants.LBLSIZE).trim();
53 level = DumpArchiveUtil.convert32(buffer, 692);
54 filesys = DumpArchiveUtil.decode(encoding, buffer, 696, DumpArchiveConstants.NAMELEN).trim();
55 devname = DumpArchiveUtil.decode(encoding, buffer, 760, DumpArchiveConstants.NAMELEN).trim();
56 hostname = DumpArchiveUtil.decode(encoding, buffer, 824, DumpArchiveConstants.NAMELEN).trim();
57 flags = DumpArchiveUtil.convert32(buffer, 888);
58 firstrec = DumpArchiveUtil.convert32(buffer, 892);
59 ntrec = DumpArchiveUtil.convert32(buffer, 896);
60
61
62 }
63
64 @Override
65 public boolean equals(final Object obj) {
66 if (this == obj) {
67 return true;
68 }
69 if (obj == null) {
70 return false;
71 }
72 if (getClass() != obj.getClass()) {
73 return false;
74 }
75 final DumpArchiveSummary other = (DumpArchiveSummary) obj;
76 return Objects.equals(devname, other.devname) && dumpDate == other.dumpDate && Objects.equals(hostname, other.hostname);
77 }
78
79
80
81
82
83
84 public String getDevname() {
85 return devname;
86 }
87
88
89
90
91
92
93 public Date getDumpDate() {
94 return new Date(dumpDate);
95 }
96
97
98
99
100
101
102 public String getFilesystem() {
103 return filesys;
104 }
105
106
107
108
109
110
111 public int getFirstRecord() {
112 return firstrec;
113 }
114
115
116
117
118
119
120 public int getFlags() {
121 return flags;
122 }
123
124
125
126
127
128
129 public String getHostname() {
130 return hostname;
131 }
132
133
134
135
136
137
138 public String getLabel() {
139 return label;
140 }
141
142
143
144
145
146
147
148
149 public int getLevel() {
150 return level;
151 }
152
153
154
155
156
157
158 public int getNTRec() {
159 return ntrec;
160 }
161
162
163
164
165
166
167 public Date getPreviousDumpDate() {
168 return new Date(previousDumpDate);
169 }
170
171
172
173
174
175
176 public int getVolume() {
177 return volume;
178 }
179
180 @Override
181 public int hashCode() {
182 return Objects.hash(devname, dumpDate, hostname);
183 }
184
185
186
187
188
189
190 public boolean isCompressed() {
191 return (flags & 0x0080) == 0x0080;
192 }
193
194
195
196
197
198
199 public boolean isExtendedAttributes() {
200 return (flags & 0x8000) == 0x8000;
201 }
202
203
204
205
206
207
208 public boolean isMetaDataOnly() {
209 return (flags & 0x0100) == 0x0100;
210 }
211
212
213
214
215
216
217 public boolean isNewHeader() {
218 return (flags & 0x0001) == 0x0001;
219 }
220
221
222
223
224
225
226 public boolean isNewInode() {
227 return (flags & 0x0002) == 0x0002;
228 }
229
230
231
232
233
234
235 public void setDevname(final String devname) {
236 this.devname = devname;
237 }
238
239
240
241
242
243
244 public void setDumpDate(final Date dumpDate) {
245 this.dumpDate = dumpDate.getTime();
246 }
247
248
249
250
251
252
253 public void setFilesystem(final String fileSystem) {
254 this.filesys = fileSystem;
255 }
256
257
258
259
260
261
262 public void setFirstRecord(final int firstrec) {
263 this.firstrec = firstrec;
264 }
265
266
267
268
269
270
271 public void setFlags(final int flags) {
272 this.flags = flags;
273 }
274
275
276
277
278
279
280 public void setHostname(final String hostname) {
281 this.hostname = hostname;
282 }
283
284
285
286
287
288
289 public void setLabel(final String label) {
290 this.label = label;
291 }
292
293
294
295
296
297
298 public void setLevel(final int level) {
299 this.level = level;
300 }
301
302
303
304
305
306
307 public void setNTRec(final int ntrec) {
308 this.ntrec = ntrec;
309 }
310
311
312
313
314
315
316 public void setPreviousDumpDate(final Date previousDumpDate) {
317 this.previousDumpDate = previousDumpDate.getTime();
318 }
319
320
321
322
323
324
325 public void setVolume(final int volume) {
326 this.volume = volume;
327 }
328 }