MainHeader.java

  1. /*
  2.  *  Licensed to the Apache Software Foundation (ASF) under one or more
  3.  *  contributor license agreements.  See the NOTICE file distributed with
  4.  *  this work for additional information regarding copyright ownership.
  5.  *  The ASF licenses this file to You under the Apache License, Version 2.0
  6.  *  (the "License"); you may not use this file except in compliance with
  7.  *  the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  *  Unless required by applicable law or agreed to in writing, software
  12.  *  distributed under the License is distributed on an "AS IS" BASIS,
  13.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  *  See the License for the specific language governing permissions and
  15.  *  limitations under the License.
  16.  */
  17. package org.apache.commons.compress.archivers.arj;

  18. import java.util.Arrays;

  19. final class MainHeader {

  20.     static final class Flags {
  21.         static final int GARBLED = 0x01;
  22.         static final int OLD_SECURED_NEW_ANSI_PAGE = 0x02;
  23.         static final int VOLUME = 0x04;
  24.         static final int ARJPROT = 0x08;
  25.         static final int PATHSYM = 0x10;
  26.         static final int BACKUP = 0x20;
  27.         static final int SECURED = 0x40;
  28.         static final int ALTNAME = 0x80;
  29.     }

  30.     static final class HostOS {
  31.         static final int MS_DOS = 0;
  32.         static final int PRIMOS = 1;
  33.         static final int UNIX = 2;
  34.         static final int AMIGA = 3;
  35.         static final int MAC_OS = 4;
  36.         static final int OS2 = 5;
  37.         static final int APPLE_GS = 6;
  38.         static final int ATARI_ST = 7;
  39.         static final int NeXT = 8;
  40.         static final int VAX_VMS = 9;
  41.         static final int WIN95 = 10;
  42.         static final int WIN32 = 11;
  43.     }

  44.     int archiverVersionNumber;
  45.     int minVersionToExtract;
  46.     int hostOS;
  47.     int arjFlags;
  48.     int securityVersion;
  49.     int fileType;
  50.     int reserved;
  51.     int dateTimeCreated;
  52.     int dateTimeModified;
  53.     long archiveSize;
  54.     int securityEnvelopeFilePosition;
  55.     int fileSpecPosition;
  56.     int securityEnvelopeLength;
  57.     int encryptionVersion;
  58.     int lastChapter;
  59.     int arjProtectionFactor;
  60.     int arjFlags2;
  61.     String name;
  62.     String comment;
  63.     byte[] extendedHeaderBytes;

  64.     @Override
  65.     public String toString() {
  66.         final StringBuilder builder = new StringBuilder();
  67.         builder.append("MainHeader [archiverVersionNumber=");
  68.         builder.append(archiverVersionNumber);
  69.         builder.append(", minVersionToExtract=");
  70.         builder.append(minVersionToExtract);
  71.         builder.append(", hostOS=");
  72.         builder.append(hostOS);
  73.         builder.append(", arjFlags=");
  74.         builder.append(arjFlags);
  75.         builder.append(", securityVersion=");
  76.         builder.append(securityVersion);
  77.         builder.append(", fileType=");
  78.         builder.append(fileType);
  79.         builder.append(", reserved=");
  80.         builder.append(reserved);
  81.         builder.append(", dateTimeCreated=");
  82.         builder.append(dateTimeCreated);
  83.         builder.append(", dateTimeModified=");
  84.         builder.append(dateTimeModified);
  85.         builder.append(", archiveSize=");
  86.         builder.append(archiveSize);
  87.         builder.append(", securityEnvelopeFilePosition=");
  88.         builder.append(securityEnvelopeFilePosition);
  89.         builder.append(", fileSpecPosition=");
  90.         builder.append(fileSpecPosition);
  91.         builder.append(", securityEnvelopeLength=");
  92.         builder.append(securityEnvelopeLength);
  93.         builder.append(", encryptionVersion=");
  94.         builder.append(encryptionVersion);
  95.         builder.append(", lastChapter=");
  96.         builder.append(lastChapter);
  97.         builder.append(", arjProtectionFactor=");
  98.         builder.append(arjProtectionFactor);
  99.         builder.append(", arjFlags2=");
  100.         builder.append(arjFlags2);
  101.         builder.append(", name=");
  102.         builder.append(name);
  103.         builder.append(", comment=");
  104.         builder.append(comment);
  105.         builder.append(", extendedHeaderBytes=");
  106.         builder.append(Arrays.toString(extendedHeaderBytes));
  107.         builder.append("]");
  108.         return builder.toString();
  109.     }
  110. }