/* */ package NET.worlds.network; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Gamma; /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.scape.Restorer; /* */ import NET.worlds.scape.Saver; /* */ import NET.worlds.scape.SuperRoot; /* */ import java.io.File; /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ import java.io.Serializable; /* */ import java.net.MalformedURLException; /* */ import java.util.Hashtable; /* */ import java.util.StringTokenizer; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class URL /* */ implements Serializable /* */ { /* */ static final long serialVersionUID = 1L; /* */ private String _url; /* */ private static Hashtable psConversion; /* */ private static IniFile protocols; /* */ private static String currentDir; /* */ private static URL home; /* */ private static URL file; /* */ private static boolean useCachedFiles; /* */ /* */ public URL(SuperRoot reference, String urlstr) /* */ throws MalformedURLException /* */ { /* 196 */ this(getBestContainer(reference), urlstr); /* */ } /* */ /* */ /* */ /* */ public URL(URL reference, String urlstr) /* */ throws MalformedURLException /* */ { /* 204 */ if (isAbsolute(urlstr)) { /* 205 */ this._url = normalize(urlstr); /* */ } else { /* 207 */ this._url = ("rel:" + reference.getAbsolute(urlstr)); /* */ } /* */ } /* */ /* */ /* */ public URL(String urlstr) /* */ throws MalformedURLException /* */ { /* 215 */ this(null, urlstr); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static URL make(String s) /* */ { /* 239 */ return make(getCurDir(), s); /* */ } /* */ /* */ /* */ /* */ public static URL make(URL url, String s) /* */ { /* */ try /* */ { /* 248 */ return new URL(url, s); /* */ } catch (MalformedURLException e) { /* 250 */ e.printStackTrace(System.out); /* 251 */ throw new Error("Can't make URL"); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private String getAbsolute(String urlstr) /* */ throws MalformedURLException /* */ { /* 266 */ if (!isAbsolute(urlstr)) { /* 267 */ urlstr = this._url.substring(0, getBaseIndex()) + urlstr; /* */ } /* 269 */ if (urlstr.startsWith("rel:")) { /* 270 */ urlstr = urlstr.substring(4); /* */ } /* 272 */ return normalize(urlstr); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private int getBaseIndex() /* */ { /* 281 */ int i = getPackageIndex(); /* */ /* 283 */ if (this._url.endsWith(".class")) { /* 284 */ int lastDot = this._url.lastIndexOf('.', this._url.length() - 7) + 1; /* 285 */ if (lastDot > i) { /* 286 */ i = lastDot; /* */ } /* */ } /* 289 */ return i; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String getAbsolute() /* */ { /* 303 */ if (this._url.startsWith("rel:")) /* 304 */ return this._url.substring(4); /* 305 */ return this._url; /* */ } /* */ /* */ /* */ public String toString() /* */ { /* 311 */ return getInternal(); /* */ } /* */ /* */ public String getInternal() /* */ { /* 316 */ return this._url; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public String getBase() /* */ { /* 325 */ return this._url.substring(getBaseIndex()); /* */ } /* */ /* */ /* */ /* */ /* */ public String getBaseWithoutExt() /* */ { /* 333 */ int start = getBaseIndex(); /* 334 */ int end = this._url.lastIndexOf('.'); /* 335 */ if (end < start) /* 336 */ end = this._url.length(); /* 337 */ return this._url.substring(start, end); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static boolean isAbsolute(String urlstr) /* */ { /* 350 */ return (urlstr != null) && ( /* 351 */ (urlstr.indexOf(':') >= 0) || /* 352 */ (urlstr.replace('\\', '/').startsWith("//"))); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static String normalize(String url) /* */ throws MalformedURLException /* */ { /* 395 */ if (url == null) { /* 396 */ throw new MalformedURLException("null URL string"); /* */ } /* 398 */ url = url.replace('\\', '/').trim(); /* */ /* */ /* 401 */ int pathi = url.indexOf(':') + 1; /* */ /* 403 */ if (pathi == 1) { /* 404 */ throw new MalformedURLException("Missing protocol specifier"); /* */ } /* 406 */ boolean hasHost = url.regionMatches(pathi, "//", 0, 2); /* */ /* */ /* 409 */ if (pathi <= 2) /* */ { /* 411 */ if ((pathi == 0) && (!hasHost)) { /* 412 */ throw new MalformedURLException("Missing protocol specifier"); /* */ } /* 414 */ url = "file:" + url; /* 415 */ pathi = 5; /* */ } /* */ /* */ /* 419 */ if (url.lastIndexOf('/', pathi - 1) >= 0) { /* 420 */ throw new MalformedURLException("/ in protocol specifier of " + url); /* */ } /* */ /* 423 */ url = url.substring(0, pathi).toLowerCase() + url.substring(pathi); /* */ /* */ /* 426 */ if (hasHost) /* */ { /* 428 */ pathi = url.indexOf('/', pathi + 2) + 1; /* 429 */ if (pathi == 0) { /* 430 */ url = url + '/'; /* 431 */ pathi = url.length(); /* */ } /* */ } /* */ /* 435 */ if (url.startsWith("rel:")) { /* 436 */ url = normalize(url.substring(4)); /* 437 */ if (url.startsWith("rel:")) /* 438 */ return url; /* 439 */ return "rel:" + url; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* 447 */ if (url.startsWith("file:")) { /* 448 */ url = "file:" + validateFile(url.substring(5)); /* */ /* */ /* 451 */ if (!hasHost) { /* 452 */ assert (url.indexOf(':', 5) == 6); /* 453 */ assert (url.charAt(7) == '/'); /* 454 */ pathi += 3; /* */ } /* 456 */ } else if ((url.startsWith("http")) && /* 457 */ (!hasHost)) { /* 458 */ throw new MalformedURLException("http must have //host/"); /* */ } /* */ /* */ /* 462 */ return url.substring(0, pathi) + removeDots(url.substring(pathi)); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static String validateFile(String p) /* */ throws MalformedURLException /* */ { /* 481 */ if (p.startsWith("//")) { /* 482 */ int slash = p.indexOf('/', 2); /* 483 */ if (slash < 0) /* 484 */ p = p + "/"; /* 485 */ return p; /* */ } /* */ /* 488 */ p = p.toLowerCase(); /* 489 */ int colon = p.indexOf(':'); /* */ /* */ /* 492 */ if (colon != 1) /* */ { /* */ /* */ /* 496 */ if (p.indexOf('/') == 0) { /* 497 */ return currentDir.substring(0, 2) + p; /* */ } /* 499 */ return currentDir + p; /* */ } /* */ /* 502 */ if (p.indexOf('/') != 2) { /* 503 */ throw new MalformedURLException("Slash must follow colon"); /* */ } /* */ /* 506 */ char drive = Character.toLowerCase(p.charAt(0)); /* 507 */ if (!Character.isLowerCase(drive)) { /* 508 */ throw new MalformedURLException("Invalid drive letter"); /* */ } /* 510 */ return drive + p.substring(1); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String getRelativeTo(URL reference) /* */ { /* 529 */ if ((reference == null) || (!this._url.startsWith("rel:"))) { /* 530 */ return this._url; /* */ } /* 532 */ String url = unalias(); /* 533 */ String ref = reference.unalias(); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 542 */ int pathStart = ref.indexOf(':') + 1; /* */ /* 544 */ boolean isLocal = pathStart == 2; /* */ /* */ /* */ /* */ /* 549 */ if (!isLocal) /* */ { /* */ /* */ /* 553 */ String hasHost = null; /* */ /* */ /* 556 */ if (ref.regionMatches(pathStart, "//", 0, 2)) { /* 557 */ hasHost = ref; /* 558 */ } else if (url.regionMatches(pathStart, "//", 0, 2)) { /* 559 */ hasHost = url; /* */ } /* 561 */ if (hasHost != null) /* */ { /* 563 */ pathStart = hasHost.indexOf('/', pathStart + 2) + 1; /* */ /* */ /* 566 */ if (pathStart == 0) { /* 567 */ return this._url; /* */ } /* */ } /* */ } /* */ /* */ /* */ /* 574 */ if (!ref.regionMatches(isLocal, 0, url, 0, pathStart)) { /* 575 */ return this._url; /* */ } /* */ /* */ /* */ /* 580 */ int noncommonStart = pathStart; /* 581 */ int len = Math.min(url.length(), ref.length()); /* 582 */ for (int common = pathStart; common < len; common++) { /* 583 */ char c = url.charAt(common); /* 584 */ char d = ref.charAt(common); /* 585 */ if ((c != d) && ( /* 586 */ (!isLocal) || /* 587 */ (Character.toLowerCase(c) != Character.toLowerCase(d)))) { /* */ break; /* */ } /* 590 */ if (c == '/') { /* 591 */ noncommonStart = common + 1; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* 599 */ url = url.substring(noncommonStart); /* */ /* */ /* 602 */ int pos = noncommonStart; /* */ /* 604 */ while ((pos = ref.indexOf('/', pos) + 1) != 0) { /* 605 */ url = "../" + url; /* */ /* */ /* 608 */ if (this._url.startsWith("rel:home:")) { /* 609 */ return this._url; /* */ } /* */ } /* 612 */ return url; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String getRelativeTo(SuperRoot r) /* */ { /* 624 */ return getRelativeTo(getBestContainer(r)); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static URL getBestContainer(SuperRoot sr) /* */ { /* 633 */ URL url = null; /* 634 */ if (sr != null) { /* 635 */ url = sr.getContainingSourceURL(); /* */ } /* 637 */ return url == null ? getCurDir() : url; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String getRelativeTo(URL u, SuperRoot r) /* */ { /* 652 */ if (u == null) /* 653 */ return null; /* 654 */ return u.getRelativeTo(r); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static URL getHome() /* */ { /* 689 */ return home; /* */ } /* */ /* */ public static String homeUnalias(String s) /* */ { /* 694 */ return make("home:" + s).unalias(); /* */ } /* */ /* */ /* */ /* */ /* */ public static URL getContainingOrCurDir(SuperRoot t) /* */ { /* 702 */ URL dir = t.getContainingSourceURL(); /* 703 */ if (dir == null) { /* 704 */ return getCurDir(); /* */ } /* 706 */ return make(dir._url.substring(0, dir.getBaseIndex())); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static void setAvatarServer(String url) /* */ { /* 722 */ String avURL = protocols.getIniString("avatar", url); /* */ try { /* 724 */ psConversion.put("avatar", new URL(new URL(avURL).unalias())); /* */ } catch (MalformedURLException e) { /* 726 */ System.out.println("Avatar protocol is invalid."); /* 727 */ if (!$assertionsDisabled) throw new AssertionError(); /* */ } /* */ } /* */ /* */ static /* */ { /* 663 */ psConversion = new Hashtable(); /* */ /* 665 */ protocols = new IniFile("Protocol"); /* */ /* */ /* */ /* */ /* */ /* 671 */ currentDir = System.getProperty("user.dir").replace('\\', '/'); /* 672 */ assert ((currentDir.charAt(1) == ':') || (currentDir.startsWith("//"))); /* */ try { /* 674 */ currentDir = validateFile(currentDir); /* */ } catch (MalformedURLException e) { /* 676 */ e.printStackTrace(System.out); /* 677 */ if (!$assertionsDisabled) { throw new AssertionError(); /* */ } /* */ } /* */ /* 681 */ if (!currentDir.endsWith("/")) { /* 682 */ currentDir += "/"; /* */ } /* */ /* 685 */ home = make(Gamma.getHome()); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 709 */ file = make("file:"); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 717 */ psConversion.put("home", home); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 731 */ useCachedFiles = true; /* */ /* */ /* 734 */ useCachedFiles = IniFile.gamma().getIniInt("useNetworkAvatars", 1) == 1; /* */ /* */ /* 737 */ int override = IniFile.override().getIniInt("useNetworkAvatars", -1); /* */ /* 739 */ if (override != -1) { /* 740 */ useCachedFiles = override == 1; /* */ } /* */ /* 743 */ String avatarDir = IniFile.gamma().getIniString("avatarDir", "avatar/"); /* */ /* 745 */ if (!avatarDir.endsWith("/")) { /* 746 */ avatarDir = avatarDir + "/"; /* */ } /* */ /* 749 */ if (useCachedFiles) { /* 750 */ setAvatarServer(NetUpdate.getUpgradeServerURL() + avatarDir); /* */ } else { /* 752 */ setAvatarServer("home:avatars/"); /* */ } /* */ } /* */ /* */ public static boolean usingCachedAvatars() { /* 757 */ return useCachedFiles; /* */ } /* */ /* */ public static void setHttpServer(String url) { /* 761 */ psConversion.put("worldshttp", make(url)); /* */ } /* */ /* */ /* */ /* */ /* */ public static URL getCurDir() /* */ { /* 769 */ return file; /* */ } /* */ /* 772 */ private static URL avatar = make("avatar:"); /* */ /* */ public static URL getAvatar() /* */ { /* 776 */ return avatar; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private int getPackageIndex() /* */ { /* 791 */ int i = this._url.lastIndexOf('/') + 1; /* 792 */ if (i == 0) { /* 793 */ i = this._url.indexOf(':') + 1; /* 794 */ if ((i == 4) && (this._url.startsWith("rel:"))) /* 795 */ i = this._url.indexOf(':', 4) + 1; /* */ } /* 797 */ return i; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String unalias() /* */ { /* 815 */ String url = getAbsolute(); /* */ /* */ /* */ /* 819 */ if (url.endsWith(".class")) { /* 820 */ int base = getPackageIndex(); /* 821 */ int len = url.length(); /* */ /* 823 */ url = url.substring(0, base) + /* 824 */ url.substring(base, len - 6).replace('.', '/') + ".class"; /* */ } /* */ /* */ /* 828 */ int protLen = url.indexOf(':'); /* 829 */ String prot = url.substring(0, protLen); /* 830 */ Object alias = psConversion.get(prot); /* */ /* */ /* 833 */ if (alias == null) /* */ { /* */ /* */ /* */ /* 838 */ psConversion.put(prot, psConversion); /* */ /* 840 */ String s = protocols.getIniString(prot, ""); /* */ /* 842 */ if ((s != null) && (!s.equals(""))) { /* */ try { /* 844 */ alias = new URL(new URL(s).unalias()); /* 845 */ psConversion.put(prot, alias); /* */ } /* */ catch (MalformedURLException e) /* */ { /* 849 */ System.out.println("Invalid inifile entry for " + prot); /* */ } /* */ } /* 852 */ } else if ((prot.equals("avatar")) && (url.endsWith(".rwg"))) /* */ { /* */ /* 855 */ alias = null; /* */ } /* */ /* */ /* */ /* 860 */ if ((alias instanceof URL)) { /* 861 */ URL u = (URL)alias; /* */ /* 863 */ assert (!u._url.startsWith("rel:")); /* */ /* */ /* */ /* 867 */ if ((u._url.startsWith("file:")) && /* 868 */ (url.length() > protLen + 1) && /* 869 */ (url.charAt(protLen + 1) == '/')) { /* 870 */ protLen++; /* */ } /* */ /* 873 */ url = /* 874 */ u._url.substring(0, u.getBaseIndex()) + url.substring(protLen + 1); /* */ } /* */ /* 877 */ if (!url.startsWith("file:")) { /* 878 */ return url; /* */ } /* */ /* 881 */ url = url.substring(5); /* */ /* */ /* */ try /* */ { /* 886 */ url = normalize(validateFile(url)); /* */ } /* */ catch (MalformedURLException e) { /* 889 */ return url; /* */ } /* */ /* */ /* 893 */ assert (url.startsWith("file:")); /* 894 */ return url.substring(5); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String searchPath(String name, String path) /* */ { /* 904 */ StringTokenizer e = new StringTokenizer(path, File.pathSeparator); /* 905 */ while (e.hasMoreTokens()) { /* 906 */ String dir = e.nextToken(); /* 907 */ String expandedName = name; /* 908 */ if (!dir.equals(".")) /* 909 */ expandedName = dir + File.separator + name; /* 910 */ File f = new File(expandedName); /* 911 */ if (f.exists()) /* 912 */ return expandedName; /* */ } /* 914 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String getClassName() /* */ { /* 924 */ if (!this._url.endsWith(".class")) { /* 925 */ return null; /* */ } /* 927 */ int base = getPackageIndex(); /* 928 */ int len = this._url.length(); /* 929 */ return this._url.substring(base, len - 6); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public URL getClassDir() /* */ { /* 939 */ if (!this._url.endsWith(".class")) { /* 940 */ return null; /* */ } /* 942 */ return make(this._url.substring(0, getPackageIndex())); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public boolean endsWith(String ext) /* */ { /* 951 */ return this._url.endsWith(ext); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public String getExt() /* */ { /* 960 */ int i = this._url.lastIndexOf('.'); /* */ /* */ /* 963 */ if ((i == -1) || (this._url.indexOf('/', i) >= 0) || (this._url.indexOf(':', i) >= 0)) { /* 964 */ return ""; /* */ } /* 966 */ return this._url.substring(i); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String maybeAddExt(String url, String ext) /* */ { /* 977 */ int dot = url.lastIndexOf('.'); /* */ /* */ /* 980 */ if ((dot >= 0) && (url.indexOf('/', dot) < 0) && (url.indexOf('\\', dot) < 0)) { /* 981 */ return url; /* */ } /* */ /* 984 */ return url + ext; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static URL restore(Restorer r, String defaultExt) /* */ throws IOException /* */ { /* 1007 */ return restore(r, r.restoreString(), defaultExt); /* */ } /* */ /* */ /* */ /* */ /* */ public static URL restore(Restorer r, String url, String defaultExt) /* */ throws IOException /* */ { /* 1016 */ if (url == null) { /* 1017 */ return null; /* */ } /* 1019 */ if (defaultExt != null) { /* 1020 */ url = maybeAddExt(url, defaultExt); /* */ } /* 1022 */ if (isAbsolute(url)) { /* 1023 */ return new URL(url); /* */ } /* */ /* */ /* 1027 */ URL ref = r.getReferenceURL(); /* */ /* */ /* 1030 */ if (r.version() >= 6) /* */ { /* 1032 */ if (ref == null) { /* 1033 */ throw new IOException("No absolute base for relative URL " + /* 1034 */ url); /* */ } /* 1036 */ return new URL(ref, url); /* */ } /* */ /* */ /* */ /* 1041 */ if (url.endsWith(".class")) { /* 1042 */ return make((url.indexOf('/') < 0 ? "system:" : "file:") + url); /* */ } /* */ /* */ /* 1046 */ String s = searchPath(url, ".;.."); /* */ /* 1048 */ if (s != null) { /* 1049 */ if (ref == null) /* 1050 */ return new URL("file:" + s); /* 1051 */ URL unaliasedRef = make(ref.unalias()); /* 1052 */ String rel = new URL("rel:file:" + s).getRelativeTo(unaliasedRef); /* 1053 */ return new URL(ref, rel); /* */ } /* */ /* */ /* */ /* 1058 */ System.out.println(url + " doesn't exist in RWSHAPEPATH"); /* 1059 */ return make(ref, url); /* */ } /* */ /* */ public static URL restore(Restorer r) throws IOException /* */ { /* 1064 */ return restore(r, null); /* */ } /* */ /* */ public void save(Saver s) throws IOException /* */ { /* 1069 */ String r = getRelativeTo(s.getReferenceURL()); /* 1070 */ if ((r.startsWith("../")) || (r.startsWith("rel:file:")) || /* 1071 */ (r.startsWith("file:"))) { /* 1072 */ Console.println(Console.message("path-to-outside") + r); /* */ } /* 1074 */ s.saveString(r); /* */ } /* */ /* */ public static void save(Saver s, URL url) throws IOException /* */ { /* 1079 */ if (url == null) { /* 1080 */ s.saveString(null); /* */ } else { /* 1082 */ url.save(s); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean equals(Object o) /* */ { /* 1093 */ if ((o instanceof URL)) { /* 1094 */ URL other = (URL)o; /* 1095 */ if (this._url.equals(other.getInternal())) /* 1096 */ return true; /* 1097 */ return unalias().equals(other.unalias()); /* */ } /* 1099 */ return false; /* */ } /* */ /* */ /* */ public int hashCode() /* */ { /* 1105 */ return unalias().hashCode(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public boolean isRemote() /* */ { /* 1114 */ String s = unalias(); /* 1115 */ if ((s.startsWith("//")) || (s.indexOf(':') < 2)) { /* 1116 */ return false; /* */ } /* 1118 */ return (!s.startsWith("system:")) && (!s.startsWith("session:")); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String removeDots(String url) /* */ { /* 1139 */ url = "/" + url; /* */ /* */ /* */ /* 1143 */ int firstSubdir = 1; /* 1144 */ int nextSearch = firstSubdir - 1; /* */ int firstDot; /* 1146 */ while ((firstDot = url.indexOf("/.", nextSearch) + 1) > 0) /* */ { /* */ int firstDot; /* 1149 */ int endSlash = url.indexOf('/', firstDot); /* 1150 */ if (endSlash < 0) /* */ break; /* 1152 */ int numDots = endSlash - firstDot; /* */ /* */ /* */ /* 1156 */ for (int i = firstDot; /* 1157 */ i < endSlash; i++) { /* 1158 */ if (url.charAt(i) != '.') /* */ break; /* */ } /* 1161 */ if (i != endSlash) { /* 1162 */ nextSearch = endSlash; /* */ /* */ } /* */ else /* */ { /* */ /* */ for (;;) /* */ { /* 1170 */ if (numDots == 1) { /* 1171 */ endSlash++; /* 1172 */ break; /* */ } /* */ /* 1175 */ if (firstDot == firstSubdir) /* */ { /* */ /* 1178 */ endSlash -= numDots; /* 1179 */ firstSubdir += numDots + 1; /* 1180 */ break; /* */ } /* */ /* 1183 */ firstDot = url.lastIndexOf('/', firstDot - 2) + 1; /* 1184 */ if (firstDot <= firstSubdir) /* 1185 */ firstDot = firstSubdir; /* 1186 */ numDots--; /* */ } /* */ /* */ /* 1190 */ url = url.substring(0, firstDot) + url.substring(endSlash); /* */ /* */ /* 1193 */ nextSearch = firstSubdir - 1; /* */ } /* */ } /* */ /* 1197 */ return url.substring(1); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\URL.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */