1 11 package org.eclipse.update.core; 12 13 import java.io.*; 14 import java.net.*; 15 import java.util.jar.*; 16 17 32 public class JarEntryContentReference extends ContentReference { 33 34 private JarContentReference jarContentReference; 35 private JarEntry entry; 36 37 45 public JarEntryContentReference( 46 String id, 47 JarContentReference jarContentReference, 48 JarEntry entry) { 49 super(id, (File) null); 50 this.jarContentReference = jarContentReference; 51 this.entry = entry; 52 } 53 54 61 public InputStream getInputStream() throws IOException { 62 return jarContentReference.asJarFile().getInputStream(entry); 63 } 64 65 71 public long getInputSize() { 72 return entry.getSize(); 73 } 74 75 82 public boolean isLocalReference() { 83 return jarContentReference.isLocalReference(); 84 } 85 86 93 public URL asURL() throws IOException { 94 String fileName = 95 jarContentReference.asFile().getAbsolutePath().replace(File.separatorChar, '/'); 96 return new URL("jar:file:" + fileName + "!/" + entry.getName()); } 98 99 105 public String toString() { 106 URL url; 107 try { 108 url = asURL(); 109 } catch (IOException e) { 110 url = null; 111 } 112 if (url != null) 113 return url.toExternalForm(); 114 else 115 return getClass().getName() + "@" + hashCode(); } 117 } 118 | Popular Tags |