Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / net / URL.js
index a8aa5e5..8802082 100644 (file)
-Clazz.declarePackage ("java.net");\r
-Clazz.load (["java.util.Hashtable"], "java.net.URL", ["java.io.IOException", "java.lang.Character", "$.Error", "java.net.MalformedURLException"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.protocol = null;\r
-this.host = null;\r
-this.port = -1;\r
-this.file = null;\r
-this.query = null;\r
-this.authority = null;\r
-this.path = null;\r
-this.userInfo = null;\r
-this.ref = null;\r
-this.handler = null;\r
-this.$hashCode = -1;\r
-Clazz.instantialize (this, arguments);\r
-}, java.net, "URL", null, java.io.Serializable);\r
-Clazz.makeConstructor (c$, \r
-function (context, spec, handler) {\r
-{\r
-switch (arguments.length) {\r
-case 1:\r
-spec = context;context = handler = null;\r
-break;\r
-case 2:\r
-handler = null;\r
-break;\r
-case 3:\r
-if (context == null || Clazz.instanceOf(context, java.net.URL))\r
-break;\r
-default:\r
-alert("java.net.URL constructor format not supported");\r
-break;\r
-}\r
-context && context.valueOf && context.valueOf() == null && (context = null);\r
-}var original = spec;\r
-var i;\r
-var limit;\r
-var c;\r
-var start = 0;\r
-var newProtocol = null;\r
-var aRef = false;\r
-var isRelative = false;\r
-try {\r
-limit = spec.length;\r
-while ((limit > 0) && (spec.charAt (limit - 1) <= ' ')) {\r
-limit--;\r
-}\r
-while ((start < limit) && (spec.charAt (start) <= ' ')) {\r
-start++;\r
-}\r
-if (spec.regionMatches (true, start, "url:", 0, 4)) {\r
-start += 4;\r
-}if (start < spec.length && spec.charAt (start) == '#') {\r
-aRef = true;\r
-}for (i = start; !aRef && (i < limit) && ((c = spec.charCodeAt (i)) != 47); i++) {\r
-if (c == 58) {\r
-var s = spec.substring (start, i).toLowerCase ();\r
-if (this.isValidProtocol (s)) {\r
-newProtocol = s;\r
-start = i + 1;\r
-}break;\r
-}}\r
-this.protocol = newProtocol;\r
-if ((context != null) && ((newProtocol == null) || newProtocol.equalsIgnoreCase (context.protocol))) {\r
-if (handler == null) {\r
-handler = context.handler;\r
-}if (context.path != null && context.path.startsWith ("/")) newProtocol = null;\r
-if (newProtocol == null) {\r
-this.protocol = context.protocol;\r
-this.authority = context.authority;\r
-this.userInfo = context.userInfo;\r
-this.host = context.host;\r
-this.port = context.port;\r
-this.file = context.file;\r
-this.path = context.path;\r
-isRelative = true;\r
-}}if (this.protocol == null) {\r
-throw  new java.net.MalformedURLException ("no protocol: " + original);\r
-}if (handler == null && (handler = java.net.URL.getURLStreamHandler (this.protocol)) == null) {\r
-throw  new java.net.MalformedURLException ("unknown protocol: " + this.protocol);\r
-}this.handler = handler;\r
-i = spec.indexOf ('#', start);\r
-if (i >= 0) {\r
-this.ref = spec.substring (i + 1, limit);\r
-limit = i;\r
-}if (isRelative && start == limit) {\r
-this.query = context.query;\r
-if (this.ref == null) {\r
-this.ref = context.ref;\r
-}}handler.parseURL (this, spec, start, limit);\r
-} catch (e$$) {\r
-if (Clazz.exceptionOf (e$$, java.net.MalformedURLException)) {\r
-var e = e$$;\r
-{\r
-throw e;\r
-}\r
-} else if (Clazz.exceptionOf (e$$, Exception)) {\r
-var e = e$$;\r
-{\r
-var exception =  new java.net.MalformedURLException (e.getMessage ());\r
-exception.initCause (e);\r
-throw exception;\r
-}\r
-} else {\r
-throw e$$;\r
-}\r
-}\r
-}, "java.net.URL,~S,java.net.URLStreamHandler");\r
-Clazz.defineMethod (c$, "isValidProtocol", \r
- function (protocol) {\r
-var len = protocol.length;\r
-if (len < 1) return false;\r
-var c = protocol.charAt (0);\r
-if (!Character.isLetter (c)) return false;\r
-for (var i = 1; i < len; i++) {\r
-c = protocol.charAt (i);\r
-if (!Character.isLetterOrDigit (c) && c != '.' && c != '+' && c != '-') {\r
-return false;\r
-}}\r
-return true;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "set5", \r
-function (protocol, host, port, file, ref) {\r
-{\r
-this.protocol = protocol;\r
-this.host = host;\r
-this.authority = port == -1 ? host : host + ":" + port;\r
-this.port = port;\r
-this.file = file;\r
-this.ref = ref;\r
-this.$hashCode = -1;\r
-var q = file.lastIndexOf ('?');\r
-if (q != -1) {\r
-this.query = file.substring (q + 1);\r
-this.path = file.substring (0, q);\r
-} else this.path = file;\r
-}}, "~S,~S,~N,~S,~S");\r
-Clazz.defineMethod (c$, "set", \r
-function (protocol, host, port, authority, userInfo, path, query, ref) {\r
-{\r
-this.protocol = protocol;\r
-this.host = host;\r
-this.port = port;\r
-this.file = query == null ? path : path + "?" + query;\r
-this.userInfo = userInfo;\r
-this.path = path;\r
-this.ref = ref;\r
-this.$hashCode = -1;\r
-this.query = query;\r
-this.authority = authority;\r
-}}, "~S,~S,~N,~S,~S,~S,~S,~S");\r
-Clazz.defineMethod (c$, "getQuery", \r
-function () {\r
-return this.query;\r
-});\r
-Clazz.defineMethod (c$, "getPath", \r
-function () {\r
-return this.path;\r
-});\r
-Clazz.defineMethod (c$, "getUserInfo", \r
-function () {\r
-return this.userInfo;\r
-});\r
-Clazz.defineMethod (c$, "getAuthority", \r
-function () {\r
-return this.authority;\r
-});\r
-Clazz.defineMethod (c$, "getPort", \r
-function () {\r
-return this.port;\r
-});\r
-Clazz.defineMethod (c$, "getDefaultPort", \r
-function () {\r
-return this.handler.getDefaultPort ();\r
-});\r
-Clazz.defineMethod (c$, "getProtocol", \r
-function () {\r
-return this.protocol;\r
-});\r
-Clazz.defineMethod (c$, "getHost", \r
-function () {\r
-return this.host;\r
-});\r
-Clazz.defineMethod (c$, "getFile", \r
-function () {\r
-return this.file;\r
-});\r
-Clazz.defineMethod (c$, "getRef", \r
-function () {\r
-return this.ref;\r
-});\r
-Clazz.overrideMethod (c$, "equals", \r
-function (obj) {\r
-if (!(Clazz.instanceOf (obj, java.net.URL))) return false;\r
-var u2 = obj;\r
-return this.handler.equals2 (this, u2);\r
-}, "~O");\r
-Clazz.overrideMethod (c$, "hashCode", \r
-function () {\r
-if (this.$hashCode != -1) return this.$hashCode;\r
-this.$hashCode = this.handler.hashCode (this);\r
-return this.$hashCode;\r
-});\r
-Clazz.defineMethod (c$, "sameFile", \r
-function (other) {\r
-return this.handler.sameFile (this, other);\r
-}, "java.net.URL");\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-return this.toExternalForm ();\r
-});\r
-Clazz.defineMethod (c$, "toExternalForm", \r
-function () {\r
-return this.handler.toExternalForm (this);\r
-});\r
-Clazz.defineMethod (c$, "openConnection", \r
-function () {\r
-return this.handler.openConnection (this);\r
-});\r
-Clazz.defineMethod (c$, "openStream", \r
-function () {\r
-return this.openConnection ().getInputStream ();\r
-});\r
-Clazz.defineMethod (c$, "getContent", \r
-function () {\r
-return this.openConnection ().getInputStream ();\r
-});\r
-c$.setURLStreamHandlerFactory = Clazz.defineMethod (c$, "setURLStreamHandlerFactory", \r
-function (fac) {\r
-{\r
-if (java.net.URL.factory != null) {\r
-throw  new Error ("factory already defined");\r
-}var security = System.getSecurityManager ();\r
-if (security != null) {\r
-security.checkSetFactory ();\r
-}java.net.URL.handlers.clear ();\r
-java.net.URL.factory = fac;\r
-}}, "java.net.URLStreamHandlerFactory");\r
-c$.getURLStreamHandler = Clazz.defineMethod (c$, "getURLStreamHandler", \r
-function (protocol) {\r
-var handler = java.net.URL.handlers.get (protocol);\r
-if (handler == null) {\r
-if (java.net.URL.factory != null) {\r
-handler = java.net.URL.factory.createURLStreamHandler (protocol);\r
-}}return handler;\r
-}, "~S");\r
-Clazz.defineStatics (c$,\r
-"factory", null);\r
-c$.handlers = c$.prototype.handlers =  new java.util.Hashtable ();\r
-c$.streamHandlerLock = c$.prototype.streamHandlerLock =  new Clazz._O ();\r
-});\r
+Clazz.declarePackage ("java.net");
+Clazz.load (["java.util.Hashtable"], "java.net.URL", ["java.io.IOException", "java.lang.Character", "$.Error", "java.net.MalformedURLException"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.protocol = null;
+this.host = null;
+this.port = -1;
+this.file = null;
+this.query = null;
+this.authority = null;
+this.path = null;
+this.userInfo = null;
+this.ref = null;
+this.handler = null;
+this.$hashCode = -1;
+Clazz.instantialize (this, arguments);
+}, java.net, "URL", null, java.io.Serializable);
+Clazz.makeConstructor (c$, 
+function (context, spec, handler) {
+{
+switch (arguments.length) {
+case 1:
+spec = context;context = handler = null;
+break;
+case 2:
+handler = null;
+break;
+case 3:
+if (context == null || Clazz.instanceOf(context, java.net.URL))
+break;
+default:
+alert("java.net.URL constructor format not supported");
+break;
+}
+context && context.valueOf && context.valueOf() == null && (context = null);
+}var original = spec;
+var i;
+var limit;
+var c;
+var start = 0;
+var newProtocol = null;
+var aRef = false;
+var isRelative = false;
+try {
+limit = spec.length;
+while ((limit > 0) && (spec.charAt (limit - 1) <= ' ')) {
+limit--;
+}
+while ((start < limit) && (spec.charAt (start) <= ' ')) {
+start++;
+}
+if (spec.regionMatches (true, start, "url:", 0, 4)) {
+start += 4;
+}if (start < spec.length && spec.charAt (start) == '#') {
+aRef = true;
+}for (i = start; !aRef && (i < limit) && ((c = spec.charCodeAt (i)) != 47); i++) {
+if (c == 58) {
+var s = spec.substring (start, i).toLowerCase ();
+if (this.isValidProtocol (s)) {
+newProtocol = s;
+start = i + 1;
+}break;
+}}
+this.protocol = newProtocol;
+if ((context != null) && ((newProtocol == null) || newProtocol.equalsIgnoreCase (context.protocol))) {
+if (handler == null) {
+handler = context.handler;
+}if (context.path != null && context.path.startsWith ("/")) newProtocol = null;
+if (newProtocol == null) {
+this.protocol = context.protocol;
+this.authority = context.authority;
+this.userInfo = context.userInfo;
+this.host = context.host;
+this.port = context.port;
+this.file = context.file;
+this.path = context.path;
+isRelative = true;
+}}if (this.protocol == null) {
+throw  new java.net.MalformedURLException ("no protocol: " + original);
+}if (handler == null && (handler = java.net.URL.getURLStreamHandler (this.protocol)) == null) {
+throw  new java.net.MalformedURLException ("unknown protocol: " + this.protocol);
+}this.handler = handler;
+i = spec.indexOf ('#', start);
+if (i >= 0) {
+this.ref = spec.substring (i + 1, limit);
+limit = i;
+}if (isRelative && start == limit) {
+this.query = context.query;
+if (this.ref == null) {
+this.ref = context.ref;
+}}handler.parseURL (this, spec, start, limit);
+} catch (e$$) {
+if (Clazz.exceptionOf (e$$, java.net.MalformedURLException)) {
+var e = e$$;
+{
+throw e;
+}
+} else if (Clazz.exceptionOf (e$$, Exception)) {
+var e = e$$;
+{
+var exception =  new java.net.MalformedURLException (e.getMessage ());
+exception.initCause (e);
+throw exception;
+}
+} else {
+throw e$$;
+}
+}
+}, "java.net.URL,~S,java.net.URLStreamHandler");
+Clazz.defineMethod (c$, "isValidProtocol", 
+ function (protocol) {
+var len = protocol.length;
+if (len < 1) return false;
+var c = protocol.charAt (0);
+if (!Character.isLetter (c)) return false;
+for (var i = 1; i < len; i++) {
+c = protocol.charAt (i);
+if (!Character.isLetterOrDigit (c) && c != '.' && c != '+' && c != '-') {
+return false;
+}}
+return true;
+}, "~S");
+Clazz.defineMethod (c$, "set5", 
+function (protocol, host, port, file, ref) {
+{
+this.protocol = protocol;
+this.host = host;
+this.authority = port == -1 ? host : host + ":" + port;
+this.port = port;
+this.file = file;
+this.ref = ref;
+this.$hashCode = -1;
+var q = file.lastIndexOf ('?');
+if (q != -1) {
+this.query = file.substring (q + 1);
+this.path = file.substring (0, q);
+} else this.path = file;
+}}, "~S,~S,~N,~S,~S");
+Clazz.defineMethod (c$, "set", 
+function (protocol, host, port, authority, userInfo, path, query, ref) {
+{
+this.protocol = protocol;
+this.host = host;
+this.port = port;
+this.file = query == null ? path : path + "?" + query;
+this.userInfo = userInfo;
+this.path = path;
+this.ref = ref;
+this.$hashCode = -1;
+this.query = query;
+this.authority = authority;
+}}, "~S,~S,~N,~S,~S,~S,~S,~S");
+Clazz.defineMethod (c$, "getQuery", 
+function () {
+return this.query;
+});
+Clazz.defineMethod (c$, "getPath", 
+function () {
+return this.path;
+});
+Clazz.defineMethod (c$, "getUserInfo", 
+function () {
+return this.userInfo;
+});
+Clazz.defineMethod (c$, "getAuthority", 
+function () {
+return this.authority;
+});
+Clazz.defineMethod (c$, "getPort", 
+function () {
+return this.port;
+});
+Clazz.defineMethod (c$, "getDefaultPort", 
+function () {
+return this.handler.getDefaultPort ();
+});
+Clazz.defineMethod (c$, "getProtocol", 
+function () {
+return this.protocol;
+});
+Clazz.defineMethod (c$, "getHost", 
+function () {
+return this.host;
+});
+Clazz.defineMethod (c$, "getFile", 
+function () {
+return this.file;
+});
+Clazz.defineMethod (c$, "getRef", 
+function () {
+return this.ref;
+});
+Clazz.overrideMethod (c$, "equals", 
+function (obj) {
+if (!(Clazz.instanceOf (obj, java.net.URL))) return false;
+var u2 = obj;
+return this.handler.equals2 (this, u2);
+}, "~O");
+Clazz.overrideMethod (c$, "hashCode", 
+function () {
+if (this.$hashCode != -1) return this.$hashCode;
+this.$hashCode = this.handler.hashCode (this);
+return this.$hashCode;
+});
+Clazz.defineMethod (c$, "sameFile", 
+function (other) {
+return this.handler.sameFile (this, other);
+}, "java.net.URL");
+Clazz.overrideMethod (c$, "toString", 
+function () {
+return this.toExternalForm ();
+});
+Clazz.defineMethod (c$, "toExternalForm", 
+function () {
+return this.handler.toExternalForm (this);
+});
+Clazz.defineMethod (c$, "openConnection", 
+function () {
+return this.handler.openConnection (this);
+});
+Clazz.defineMethod (c$, "openStream", 
+function () {
+return this.openConnection ().getInputStream ();
+});
+Clazz.defineMethod (c$, "getContent", 
+function () {
+return this.openConnection ().getInputStream ();
+});
+c$.setURLStreamHandlerFactory = Clazz.defineMethod (c$, "setURLStreamHandlerFactory", 
+function (fac) {
+{
+if (java.net.URL.factory != null) {
+throw  new Error ("factory already defined");
+}var security = System.getSecurityManager ();
+if (security != null) {
+security.checkSetFactory ();
+}java.net.URL.handlers.clear ();
+java.net.URL.factory = fac;
+}}, "java.net.URLStreamHandlerFactory");
+c$.getURLStreamHandler = Clazz.defineMethod (c$, "getURLStreamHandler", 
+function (protocol) {
+var handler = java.net.URL.handlers.get (protocol);
+if (handler == null) {
+if (java.net.URL.factory != null) {
+handler = java.net.URL.factory.createURLStreamHandler (protocol);
+}}return handler;
+}, "~S");
+Clazz.defineStatics (c$,
+"factory", null);
+c$.handlers = c$.prototype.handlers =  new java.util.Hashtable ();
+c$.streamHandlerLock = c$.prototype.streamHandlerLock =  new Clazz._O ();
+});