home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.jar;
-
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.net.URLStreamHandler;
- import sun.net.www.ParseUtil;
-
- public class Handler extends URLStreamHandler {
- private static final String separator = "!/";
-
- protected URLConnection openConnection(URL var1) throws IOException {
- return new JarURLConnection(var1, this);
- }
-
- private int indexOfBangSlash(String var1) {
- for(int var3 = var1.length(); (var3 = var1.lastIndexOf(33, var3)) != -1; --var3) {
- if (var3 != var1.length() - 1 && var1.charAt(var3 + 1) == '/') {
- return var3 + 1;
- }
- }
-
- return -1;
- }
-
- protected void parseURL(URL var1, String var2, int var3, int var4) {
- String var5 = null;
- String var6 = null;
- int var7 = var2.indexOf(35, var4);
- boolean var8 = var7 == var3;
- if (var7 > -1) {
- var6 = var2.substring(var7 + 1, var2.length());
- if (var8) {
- var5 = var1.getFile();
- }
- }
-
- boolean var9 = var2.substring(0, 4).equalsIgnoreCase("jar:");
- var2 = var2.substring(var3, var4);
- if (var9) {
- var5 = this.parseAbsoluteSpec(var2);
- } else if (!var8) {
- var5 = this.parseContextSpec(var1, var2);
- int var10 = this.indexOfBangSlash(var5);
- String var11 = var5.substring(0, var10);
- String var12 = var5.substring(var10);
- ParseUtil var13 = new ParseUtil();
- var12 = var13.canonizeString(var12);
- var5 = var11 + var12;
- }
-
- ((URLStreamHandler)this).setURL(var1, "jar", "", -1, var5, var6);
- }
-
- private String parseAbsoluteSpec(String var1) {
- Object var2 = null;
- int var3 = -1;
- if ((var3 = this.indexOfBangSlash(var1)) == -1) {
- throw new NullPointerException("no !/ in spec");
- } else {
- try {
- String var4 = var1.substring(0, var3 - 1);
- new URL(var4);
- return var1;
- } catch (MalformedURLException var5) {
- throw new NullPointerException("invalid url: " + var1 + " (" + var5 + ")");
- }
- }
- }
-
- private String parseContextSpec(URL var1, String var2) {
- String var3 = var1.getFile();
- if (var2.startsWith("/")) {
- int var4 = this.indexOfBangSlash(var3);
- if (var4 == -1) {
- throw new NullPointerException("malformed context url:" + var1 + ": no !/");
- }
-
- var3 = var3.substring(0, var4);
- }
-
- if (!var3.endsWith("/") && !var2.startsWith("/")) {
- int var5 = var3.lastIndexOf(47);
- if (var5 == -1) {
- throw new NullPointerException("malformed context url:" + var1);
- }
-
- var3 = var3.substring(0, var5 + 1);
- }
-
- return var3 + var2;
- }
- }
-