home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / tools / java / ClassFile.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  2.2 KB  |  84 lines

  1. package sun.tools.java;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.util.zip.ZipEntry;
  8. import java.util.zip.ZipException;
  9. import java.util.zip.ZipFile;
  10.  
  11. public class ClassFile {
  12.    private File file;
  13.    private ZipFile zipFile;
  14.    private ZipEntry zipEntry;
  15.  
  16.    public ClassFile(File var1) {
  17.       this.file = var1;
  18.    }
  19.  
  20.    public ClassFile(ZipFile var1, ZipEntry var2) {
  21.       this.zipFile = var1;
  22.       this.zipEntry = var2;
  23.    }
  24.  
  25.    public boolean isZipped() {
  26.       return this.zipFile != null;
  27.    }
  28.  
  29.    public InputStream getInputStream() throws IOException {
  30.       if (this.file != null) {
  31.          return new FileInputStream(this.file);
  32.       } else {
  33.          try {
  34.             return this.zipFile.getInputStream(this.zipEntry);
  35.          } catch (ZipException var2) {
  36.             throw new IOException(((Throwable)var2).getMessage());
  37.          }
  38.       }
  39.    }
  40.  
  41.    public boolean exists() {
  42.       return this.file != null ? this.file.exists() : true;
  43.    }
  44.  
  45.    public boolean isDirectory() {
  46.       return this.file != null ? this.file.isDirectory() : this.zipEntry.getName().endsWith("/");
  47.    }
  48.  
  49.    public long lastModified() {
  50.       return this.file != null ? this.file.lastModified() : this.zipEntry.getTime();
  51.    }
  52.  
  53.    public String getPath() {
  54.       return this.file != null ? this.file.getPath() : this.zipFile.getName() + "(" + this.zipEntry.getName() + ")";
  55.    }
  56.  
  57.    public String getName() {
  58.       return this.file != null ? this.file.getName() : this.zipEntry.getName();
  59.    }
  60.  
  61.    public String getAbsoluteName() {
  62.       String var1;
  63.       if (this.file != null) {
  64.          try {
  65.             var1 = this.file.getCanonicalPath();
  66.          } catch (IOException var2) {
  67.             var1 = this.file.getAbsolutePath();
  68.          }
  69.       } else {
  70.          var1 = this.zipFile.getName() + "(" + this.zipEntry.getName() + ")";
  71.       }
  72.  
  73.       return var1;
  74.    }
  75.  
  76.    public long length() {
  77.       return this.file != null ? this.file.length() : this.zipEntry.getSize();
  78.    }
  79.  
  80.    public String toString() {
  81.       return this.file != null ? this.file.toString() : this.zipEntry.toString();
  82.    }
  83. }
  84.