1 7 8 package java.net; 9 10 import java.io.IOException ; 11 import java.util.jar.JarFile ; 12 import java.util.jar.JarEntry ; 13 import java.util.jar.Attributes ; 14 import java.util.jar.Manifest ; 15 import java.security.Permission ; 16 import sun.net.www.ParseUtil; 17 18 123 public abstract class JarURLConnection extends URLConnection { 124 125 private URL jarFileURL; 126 private String entryName; 127 128 132 protected URLConnection jarFileURLConnection; 133 134 141 142 protected JarURLConnection(URL url) throws MalformedURLException { 143 super(url); 144 parseSpecs(url); 145 } 146 147 150 private void parseSpecs(URL url) throws MalformedURLException { 151 String spec = url.getFile(); 152 153 int separator = spec.indexOf("!/"); 154 157 if (separator == -1) { 158 throw new MalformedURLException ("no !/ found in url spec:" + spec); 159 } 160 161 jarFileURL = new URL (spec.substring(0, separator++)); 162 entryName = null; 163 164 165 if (++separator != spec.length()) { 166 entryName = spec.substring(separator, spec.length()); 167 entryName = ParseUtil.decode (entryName); 168 } 169 } 170 171 176 public URL getJarFileURL() { 177 return jarFileURL; 178 } 179 180 187 public String getEntryName() { 188 return entryName; 189 } 190 191 203 public abstract JarFile getJarFile() throws IOException ; 204 205 216 public Manifest getManifest() throws IOException { 217 return getJarFile().getManifest(); 218 } 219 220 234 public JarEntry getJarEntry() throws IOException { 235 return getJarFile().getJarEntry(entryName); 236 } 237 238 250 public Attributes getAttributes() throws IOException { 251 JarEntry e = getJarEntry(); 252 return e != null ? e.getAttributes() : null; 253 } 254 255 268 public Attributes getMainAttributes() throws IOException { 269 Manifest man = getManifest(); 270 return man != null ? man.getMainAttributes() : null; 271 } 272 273 289 public java.security.cert.Certificate [] getCertificates() 290 throws IOException 291 { 292 JarEntry e = getJarEntry(); 293 return e != null ? e.getCertificates() : null; 294 } 295 } 296 297 298 299 300 301 302 | Popular Tags |