home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / zip / ZipEntry.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.3 KB  |  174 lines

  1. package java.util.zip;
  2.  
  3. import java.security.AccessController;
  4. import java.util.Date;
  5. import sun.security.action.LoadLibraryAction;
  6.  
  7. public class ZipEntry implements ZipConstants, Cloneable {
  8.    String name;
  9.    long time = -1L;
  10.    long crc = -1L;
  11.    long size = -1L;
  12.    long csize = -1L;
  13.    int method = -1;
  14.    byte[] extra;
  15.    String comment;
  16.    int flag;
  17.    int version;
  18.    long offset;
  19.    public static final int STORED = 0;
  20.    public static final int DEFLATED = 8;
  21.  
  22.    private static native void initIDs();
  23.  
  24.    public ZipEntry(String var1) {
  25.       if (var1 == null) {
  26.          throw new NullPointerException();
  27.       } else if (var1.length() > 65535) {
  28.          throw new IllegalArgumentException("entry name too long");
  29.       } else {
  30.          this.name = var1;
  31.       }
  32.    }
  33.  
  34.    public ZipEntry(ZipEntry var1) {
  35.       this.name = var1.name;
  36.       this.time = var1.time;
  37.       this.crc = var1.crc;
  38.       this.size = var1.size;
  39.       this.csize = var1.csize;
  40.       this.method = var1.method;
  41.       this.extra = var1.extra;
  42.       this.comment = var1.comment;
  43.    }
  44.  
  45.    ZipEntry(String var1, long var2) {
  46.       this.name = var1;
  47.       this.initFields(var2);
  48.    }
  49.  
  50.    private native void initFields(long var1);
  51.  
  52.    ZipEntry(long var1) {
  53.       this.initFields(var1);
  54.    }
  55.  
  56.    public String getName() {
  57.       return this.name;
  58.    }
  59.  
  60.    public void setTime(long var1) {
  61.       this.time = javaToDosTime(var1);
  62.    }
  63.  
  64.    public long getTime() {
  65.       return this.time != -1L ? dosToJavaTime(this.time) : -1L;
  66.    }
  67.  
  68.    public void setSize(long var1) {
  69.       if (var1 >= 0L && var1 <= 4294967295L) {
  70.          this.size = var1;
  71.       } else {
  72.          throw new IllegalArgumentException("invalid entry size");
  73.       }
  74.    }
  75.  
  76.    public long getSize() {
  77.       return this.size;
  78.    }
  79.  
  80.    public long getCompressedSize() {
  81.       return this.csize;
  82.    }
  83.  
  84.    public void setCompressedSize(long var1) {
  85.       this.csize = var1;
  86.    }
  87.  
  88.    public void setCrc(long var1) {
  89.       if (var1 >= 0L && var1 <= 4294967295L) {
  90.          this.crc = var1;
  91.       } else {
  92.          throw new IllegalArgumentException("invalid entry crc-32");
  93.       }
  94.    }
  95.  
  96.    public long getCrc() {
  97.       return this.crc;
  98.    }
  99.  
  100.    public void setMethod(int var1) {
  101.       if (var1 != 0 && var1 != 8) {
  102.          throw new IllegalArgumentException("invalid compression method");
  103.       } else {
  104.          this.method = var1;
  105.       }
  106.    }
  107.  
  108.    public int getMethod() {
  109.       return this.method;
  110.    }
  111.  
  112.    public void setExtra(byte[] var1) {
  113.       if (var1 != null && var1.length > 65535) {
  114.          throw new IllegalArgumentException("invalid extra field length");
  115.       } else {
  116.          this.extra = var1;
  117.       }
  118.    }
  119.  
  120.    public byte[] getExtra() {
  121.       return this.extra;
  122.    }
  123.  
  124.    public void setComment(String var1) {
  125.       if (var1 != null && var1.length() > 65535) {
  126.          throw new IllegalArgumentException("invalid entry comment length");
  127.       } else {
  128.          this.comment = var1;
  129.       }
  130.    }
  131.  
  132.    public String getComment() {
  133.       return this.comment;
  134.    }
  135.  
  136.    public boolean isDirectory() {
  137.       return this.name.endsWith("/");
  138.    }
  139.  
  140.    public String toString() {
  141.       return this.getName();
  142.    }
  143.  
  144.    private static long dosToJavaTime(long var0) {
  145.       Date var2 = new Date((int)((var0 >> 25 & 127L) + 80L), (int)((var0 >> 21 & 15L) - 1L), (int)(var0 >> 16 & 31L), (int)(var0 >> 11 & 31L), (int)(var0 >> 5 & 63L), (int)(var0 << 1 & 62L));
  146.       return var2.getTime();
  147.    }
  148.  
  149.    private static long javaToDosTime(long var0) {
  150.       Date var2 = new Date(var0);
  151.       int var3 = var2.getYear() + 1900;
  152.       return var3 < 1980 ? 2162688L : (long)(var3 - 1980 << 25 | var2.getMonth() + 1 << 21 | var2.getDate() << 16 | var2.getHours() << 11 | var2.getMinutes() << 5 | var2.getSeconds() >> 1);
  153.    }
  154.  
  155.    public int hashCode() {
  156.       return this.name.hashCode();
  157.    }
  158.  
  159.    public Object clone() {
  160.       try {
  161.          ZipEntry var1 = (ZipEntry)super.clone();
  162.          var1.extra = this.extra == null ? null : (byte[])this.extra.clone();
  163.          return var1;
  164.       } catch (CloneNotSupportedException var2) {
  165.          throw new InternalError();
  166.       }
  167.    }
  168.  
  169.    static {
  170.       AccessController.doPrivileged(new LoadLibraryAction("zip"));
  171.       initIDs();
  172.    }
  173. }
  174.