001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   https://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.commons.compress.archivers.dump;
020
021/**
022 * Various constants associated with dump archives.
023 */
024public final class DumpArchiveConstants {
025
026    /**
027     * Enumerates compression types.
028     */
029    public enum COMPRESSION_TYPE {
030
031        /**
032         * Compression code is -1.
033         */
034        UNKNOWN(-1),
035
036        /**
037         * Compression code is 0.
038         */
039        ZLIB(0),
040
041        /**
042         * Compression code is 1.
043         */
044        BZLIB(1),
045
046        /**
047         * Compression code is 2.
048         */
049        LZO(2);
050
051        /**
052         * Finds the matching enumeration value for the given code.
053         *
054         * @param code a code.
055         * @return a value, never null.
056         */
057        public static COMPRESSION_TYPE find(final int code) {
058            for (final COMPRESSION_TYPE e : values()) {
059                if (e.code == code) {
060                    return e;
061                }
062            }
063            return UNKNOWN;
064        }
065
066        final int code;
067
068        COMPRESSION_TYPE(final int code) {
069            this.code = code;
070        }
071    }
072
073    /**
074     * Enumerates the types of tape segment.
075     */
076    public enum SEGMENT_TYPE {
077
078        /**
079         * TAPE with code 1.
080         */
081        TAPE(1),
082
083        /**
084         * INODE with code 2.
085         */
086        INODE(2),
087
088        /**
089         * BITS with code 3.
090         */
091        BITS(3),
092
093        /**
094         * ADDR with code 4.
095         */
096        ADDR(4),
097
098        /**
099         * END with code 5.
100         */
101        END(5),
102
103        /**
104         * CLRI with code 6.
105         */
106        CLRI(6);
107
108        /**
109         * Finds the matching enumeration value for the given code.
110         *
111         * @param code a code.
112         * @return a value, or null if not found.
113         */
114        public static SEGMENT_TYPE find(final int code) {
115            for (final SEGMENT_TYPE e : values()) {
116                if (e.code == code) {
117                    return e;
118                }
119            }
120            return null;
121        }
122
123        final int code;
124
125        SEGMENT_TYPE(final int code) {
126            this.code = code;
127        }
128    }
129
130    /**
131     * TP_SIZE value {@value}.
132     */
133    public static final int TP_SIZE = 1024;
134
135    /**
136     * NTREC value {@value}.
137     */
138    public static final int NTREC = 10;
139
140    /**
141     * HIGH_DENSITY_NTREC value {@value}.
142     */
143    public static final int HIGH_DENSITY_NTREC = 32;
144
145    /**
146     * OFS_MAGIC value {@value}.
147     */
148    public static final int OFS_MAGIC = 60011;
149
150    /**
151     * NFS_MAGIC value {@value}.
152     */
153    public static final int NFS_MAGIC = 60012;
154
155    /**
156     * FS_UFS2_MAGIC value {@value}.
157     */
158    public static final int FS_UFS2_MAGIC = 0x19540119;
159
160    /**
161     * CHECKSUM value {@value}.
162     */
163    public static final int CHECKSUM = 84446;
164
165    /**
166     * LBLSIZE value {@value}.
167     */
168    public static final int LBLSIZE = 16;
169
170    /**
171     * NAMELEN value {@value}.
172     */
173    public static final int NAMELEN = 64;
174
175    /** Do not instantiate. */
176    private DumpArchiveConstants() {
177    }
178}