1 11 package org.eclipse.osgi.baseadaptor.bundlefile; 12 13 import java.io.*; 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 import java.util.zip.ZipEntry ; 17 18 23 public class ZipBundleEntry extends BundleEntry { 24 27 protected ZipEntry zipEntry; 28 29 32 protected BundleFile bundleFile; 33 34 39 ZipBundleEntry(ZipEntry zipEntry, BundleFile bundleFile) { 40 this.zipEntry = zipEntry; 41 this.bundleFile = bundleFile; 42 } 43 44 50 public InputStream getInputStream() throws IOException { 51 return ((ZipBundleFile) bundleFile).getZipFile().getInputStream(zipEntry); 52 } 53 54 59 public long getSize() { 60 return zipEntry.getSize(); 61 } 62 63 68 public String getName() { 69 return zipEntry.getName(); 70 } 71 72 79 public long getTime() { 80 return zipEntry.getTime(); 81 } 82 83 public URL getLocalURL() { 84 try { 85 return new URL ("jar:file:" + bundleFile.basefile.getAbsolutePath() + "!/" + zipEntry.getName()); } catch (MalformedURLException e) { 87 return null; 89 } 90 } 91 92 public URL getFileURL() { 93 try { 94 File file = bundleFile.getFile(zipEntry.getName(), false); 95 if (file != null) 96 return file.toURL(); 97 } catch (MalformedURLException e) { 98 } 100 return null; 101 } 102 } 103 | Popular Tags |