home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / util / zip / ZipEntry.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.9 KB  |  128 lines

  1. package java.util.zip;
  2.  
  3. import java.util.Date;
  4.  
  5. public class ZipEntry implements ZipConstants {
  6.    String name;
  7.    long time = -1L;
  8.    long crc = -1L;
  9.    long size = -1L;
  10.    int method = -1;
  11.    byte[] extra;
  12.    String comment;
  13.    int flag;
  14.    int version;
  15.    long csize = -1L;
  16.    long offset;
  17.    public static final int STORED = 0;
  18.    public static final int DEFLATED = 8;
  19.  
  20.    public ZipEntry(String var1) {
  21.       if (var1 == null) {
  22.          throw new NullPointerException();
  23.       } else if (var1.length() > 65535) {
  24.          throw new IllegalArgumentException("entry name too long");
  25.       } else {
  26.          this.name = var1;
  27.       }
  28.    }
  29.  
  30.    ZipEntry() {
  31.    }
  32.  
  33.    public String getName() {
  34.       return this.name;
  35.    }
  36.  
  37.    public void setTime(long var1) {
  38.       this.time = javaToDosTime(var1);
  39.    }
  40.  
  41.    public long getTime() {
  42.       return dosToJavaTime(this.time);
  43.    }
  44.  
  45.    public void setSize(long var1) {
  46.       if (var1 >= 0L && var1 <= 4294967295L) {
  47.          this.size = var1;
  48.       } else {
  49.          throw new IllegalArgumentException("invalid entry size");
  50.       }
  51.    }
  52.  
  53.    public long getSize() {
  54.       return this.size;
  55.    }
  56.  
  57.    public void setCrc(long var1) {
  58.       if (var1 >= 0L && var1 <= 4294967295L) {
  59.          this.crc = var1;
  60.       } else {
  61.          throw new IllegalArgumentException("invalid entry crc-32");
  62.       }
  63.    }
  64.  
  65.    public long getCrc() {
  66.       return this.crc;
  67.    }
  68.  
  69.    public void setMethod(int var1) {
  70.       if (var1 != 0 && var1 != 8) {
  71.          throw new IllegalArgumentException("invalid compression method");
  72.       } else {
  73.          this.method = var1;
  74.       }
  75.    }
  76.  
  77.    public int getMethod() {
  78.       return this.method;
  79.    }
  80.  
  81.    public void setExtra(byte[] var1) {
  82.       if (var1 != null && var1.length > 65535) {
  83.          throw new IllegalArgumentException("invalid extra field length");
  84.       } else {
  85.          this.extra = var1;
  86.       }
  87.    }
  88.  
  89.    public byte[] getExtra() {
  90.       return this.extra;
  91.    }
  92.  
  93.    public void setComment(String var1) {
  94.       if (var1 != null && var1.length() > 65535) {
  95.          throw new IllegalArgumentException("invalid entry comment length");
  96.       } else {
  97.          this.comment = var1;
  98.       }
  99.    }
  100.  
  101.    public String getComment() {
  102.       return this.comment;
  103.    }
  104.  
  105.    public long getCompressedSize() {
  106.       return this.csize;
  107.    }
  108.  
  109.    public boolean isDirectory() {
  110.       return this.name.endsWith("/");
  111.    }
  112.  
  113.    public String toString() {
  114.       return this.getName();
  115.    }
  116.  
  117.    private static long dosToJavaTime(long var0) {
  118.       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));
  119.       return var2.getTime();
  120.    }
  121.  
  122.    private static long javaToDosTime(long var0) {
  123.       Date var2 = new Date(var0);
  124.       int var3 = var2.getYear() + 1900;
  125.       return var3 < 1980 ? 2162688L : (long)(var3 - 1980 << 25 | var2.getMonth() + 1 << 21 | var2.getDate() << 16 | var2.getHours() << 11 | var2.getMinutes() << 5 | var2.getSeconds() >> 1);
  126.    }
  127. }
  128.