85 |
private String entry_name; |
private String entry_name; |
86 |
|
|
87 |
/** |
/** |
|
* The JarFile object for the jar file pointed to by the real URL |
|
|
*/ |
|
|
private JarFile jar_file; |
|
|
|
|
|
/** |
|
88 |
* Creates a JarURLConnection from an URL object |
* Creates a JarURLConnection from an URL object |
89 |
* |
* |
90 |
* @param URL url The URL object for this connection. |
* @param URL url The URL object for this connection. |
101 |
if (!url.getProtocol().equals ("jar")) |
if (!url.getProtocol().equals ("jar")) |
102 |
throw new MalformedURLException (url + ": Not jar protocol."); |
throw new MalformedURLException (url + ": Not jar protocol."); |
103 |
|
|
104 |
// Now, strip off the "jar:" and everything from the "!/" to the end |
String str = url.getFile(); |
|
// to get the "real" URL inside |
|
|
String url_string = url.toExternalForm(); |
|
105 |
|
|
106 |
int bang = url_string.indexOf ("!/"); |
int bang = str.indexOf ("!/"); |
107 |
if (bang == -1) |
if (bang == -1) |
108 |
throw new MalformedURLException (url + ": No `!/' in spec."); |
throw new MalformedURLException (url + ": No `!/' in spec."); |
109 |
|
|
110 |
jarFileURL = new URL (url_string.substring (4, bang)); |
jarFileURL = new URL (str.substring (0, bang)); |
111 |
if (url_string.length() == (bang + 1)) |
entry_name = str.length() == (bang + 1) ? "" : str.substring (bang + 2); |
|
entry_name = ""; |
|
|
else |
|
|
entry_name = url_string.substring (bang + 2); |
|
112 |
} |
} |
113 |
|
|
114 |
/** |
/** |
143 |
*/ |
*/ |
144 |
public JarEntry getJarEntry () throws IOException |
public JarEntry getJarEntry () throws IOException |
145 |
{ |
{ |
146 |
if (jar_file == null) |
JarFile file = getJarFile(); |
|
jar_file = getJarFile(); |
|
147 |
|
|
148 |
return jar_file.getJarEntry(entry_name); |
return file != null ? file.getJarEntry (entry_name) : null; |
149 |
} |
} |
150 |
|
|
151 |
/** |
/** |
207 |
*/ |
*/ |
208 |
public Manifest getManifest () throws IOException |
public Manifest getManifest () throws IOException |
209 |
{ |
{ |
210 |
if (jar_file == null) |
JarFile file = getJarFile(); |
|
jar_file = getJarFile(); |
|
211 |
|
|
212 |
return jar_file.getManifest(); |
return file != null ? file.getManifest() : null; |
213 |
} |
} |
214 |
} |
} |