1 23 package com.sun.enterprise.util; 24 25 import java.io.InputStream ; 26 import java.io.FileInputStream ; 27 import java.io.File ; 28 29 public class JarEntrySource { 30 public JarEntrySource(File file) { 31 this.markOnly = false; 32 this.name = file.getPath().replace(File.separatorChar, '/'); 33 this.file = file; 34 } 35 36 public JarEntrySource(String name, File file) { 37 this.markOnly = false; 38 this.name = name; 39 this.file = file; 40 } 41 42 public JarEntrySource(String name, InputStream is) { 43 this.markOnly = false; 44 this.name = name; 45 this.is = is; 46 } 47 48 public JarEntrySource(String name) { 49 this.markOnly = true; 50 this.name = name; 51 } 52 55 public boolean isMarkOnly() { 56 return markOnly; 57 } 58 59 public long getTime() { 60 if (file != null) { 61 return file.lastModified(); 62 } else { 63 return 0; } 65 } 66 67 public long getLength() { 68 if (file != null) { 69 return file.length(); 70 } else { 71 return 0; } 73 } 74 75 public String getName() { 76 return name; 77 } 78 79 public InputStream getInputStream() { 80 if (file != null) { 81 try { 82 return new FileInputStream (file); 83 } catch (Exception ex) { 84 return null; 85 } 86 } else { 87 return is; 88 } 89 } 90 91 private boolean markOnly; private String name; private InputStream is; private File file; private long modifiedTime; 97 public String toString() { 98 return file == null ? getName() : file.toString(); 99 } 100 } 101 | Popular Tags |