1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.commons.compress.archivers.sevenz;
20
21 import java.util.BitSet;
22
23 final class Archive {
24
25 private static String lengthOf(final long[] a) {
26 return a == null ? "(null)" : Integer.toString(a.length);
27 }
28
29 private static String lengthOf(final Object[] a) {
30 return a == null ? "(null)" : Integer.toString(a.length);
31 }
32
33 /** Offset from beginning of file + SIGNATURE_HEADER_SIZE to packed streams. */
34 long packPos;
35
36 /** Size of each packed stream. */
37 long[] packSizes = {};
38
39 /** Whether each particular packed streams has a CRC. */
40 BitSet packCrcsDefined;
41
42 /** CRCs for each packed stream, valid only if that packed stream has one. */
43 long[] packCrcs;
44
45 /** Properties of solid compression blocks. */
46 Folder[] folders = Folder.EMPTY_FOLDER_ARRAY;
47
48 /** Temporary properties for non-empty files (subsumed into the files array later). */
49 SubStreamsInfo subStreamsInfo;
50
51 /** The files and directories in the archive. */
52 SevenZArchiveEntry[] files = SevenZArchiveEntry.EMPTY_SEVEN_Z_ARCHIVE_ENTRY_ARRAY;
53
54 /** Mapping between folders, files and streams. */
55 StreamMap streamMap;
56
57 @Override
58 public String toString() {
59 return "Archive with packed streams starting at offset " + packPos + ", " + lengthOf(packSizes) + " pack sizes, " + lengthOf(packCrcs) + " CRCs, "
60 + lengthOf(folders) + " folders, " + lengthOf(files) + " files and " + streamMap;
61 }
62 }