JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / jalview / util / UrlLink.js
index c50c6ae..a28894b 100644 (file)
-Clazz.declarePackage ("jalview.util");\r
-Clazz.load (null, "jalview.util.UrlLink", ["jalview.jsdev.RegExp", "java.util.Vector"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.url_suffix = null;\r
-this.url_prefix = null;\r
-this.target = null;\r
-this.label = null;\r
-this.regexReplace = null;\r
-this.dynamic = false;\r
-this.invalidMessage = null;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.util, "UrlLink");\r
-Clazz.makeConstructor (c$, \r
-function (link) {\r
-var sep = link.indexOf ("|");\r
-var psqid = link.indexOf ("$SEQUENCE_ID");\r
-if (psqid > -1) {\r
-this.dynamic = true;\r
-var p = sep;\r
-do {\r
-sep = p;\r
-p = link.indexOf ("|", sep + 1);\r
-} while (p > sep && p < psqid);\r
-this.label = link.substring (0, sep);\r
-if (this.label.indexOf ("|") > -1) {\r
-this.target = this.label.substring (0, this.label.indexOf ("|"));\r
-} else if (this.label.indexOf (" ") > 2) {\r
-this.target = this.label.substring (0, this.label.indexOf (" "));\r
-} else {\r
-this.target = this.label;\r
-}this.url_prefix = link.substring (sep + 1, psqid);\r
-if (link.indexOf ("$SEQUENCE_ID=/") == psqid && (p = link.indexOf ("/=$", psqid + 14)) > psqid + 14) {\r
-this.url_suffix = link.substring (p + 3);\r
-this.regexReplace = link.substring (psqid + 14, p);\r
-try {\r
-var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/");\r
-if (rg == null) {\r
-this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n";\r
-}} catch (e) {\r
-if (Clazz.exceptionOf (e, Exception)) {\r
-this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n";\r
-} else {\r
-throw e;\r
-}\r
-}\r
-} else {\r
-this.regexReplace = null;\r
-if (link.indexOf ("$SEQUENCE_ID$") == psqid) {\r
-this.url_suffix = link.substring (psqid + 13);\r
-this.regexReplace = null;\r
-} else {\r
-this.invalidMessage = "Warning: invalid regex structure for URL link : " + link;\r
-}}} else {\r
-this.target = link.substring (0, sep);\r
-this.label = link.substring (0, sep = link.lastIndexOf ("|"));\r
-this.url_prefix = link.substring (sep + 1);\r
-this.regexReplace = null;\r
-this.url_suffix = null;\r
-}}, "~S");\r
-Clazz.defineMethod (c$, "getUrl_suffix", \r
-function () {\r
-return this.url_suffix;\r
-});\r
-Clazz.defineMethod (c$, "getUrl_prefix", \r
-function () {\r
-return this.url_prefix;\r
-});\r
-Clazz.defineMethod (c$, "getTarget", \r
-function () {\r
-return this.target;\r
-});\r
-Clazz.defineMethod (c$, "getLabel", \r
-function () {\r
-return this.label;\r
-});\r
-Clazz.defineMethod (c$, "getRegexReplace", \r
-function () {\r
-return this.regexReplace;\r
-});\r
-Clazz.defineMethod (c$, "getInvalidMessage", \r
-function () {\r
-return this.invalidMessage;\r
-});\r
-Clazz.defineMethod (c$, "isValid", \r
-function () {\r
-return this.invalidMessage == null;\r
-});\r
-Clazz.defineMethod (c$, "makeUrls", \r
-function (idstring, onlyIfMatches) {\r
-if (this.dynamic) {\r
-if (this.regexReplace != null) {\r
-var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/");\r
-if (rg.search (idstring)) {\r
-var ns = rg.numSubs ();\r
-if (ns == 0) {\r
-return  Clazz.newArray (-1, [rg.stringMatchedI (ns), this.url_prefix + rg.stringMatched () + this.url_suffix]);\r
-} else {\r
-for (var s = 0; s <= rg.numSubs (); s++) {\r
-System.err.println ("Sub " + s + " : " + rg.matchedFromI (s) + " : " + rg.matchedToI (s) + " : '" + rg.stringMatchedI (s) + "'");\r
-}\r
-var subs =  new java.util.Vector ();\r
-var s = 0;\r
-while (s <= ns) {\r
-if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) {\r
-var r = s + 1;\r
-var mtch = "";\r
-while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) {\r
-if (rg.matchedFromI (r) > -1) {\r
-mtch += rg.stringMatchedI (r);\r
-}r++;\r
-}\r
-if (mtch.length > 0) {\r
-subs.addElement (mtch);\r
-subs.addElement (this.url_prefix + mtch + this.url_suffix);\r
-}s = r;\r
-} else {\r
-if (rg.matchedFromI (s) > -1) {\r
-subs.addElement (rg.stringMatchedI (s));\r
-subs.addElement (this.url_prefix + rg.stringMatchedI (s) + this.url_suffix);\r
-}s++;\r
-}}\r
-var res =  new Array (subs.size ());\r
-for (var r = 0, rs = subs.size (); r < rs; r++) {\r
-res[r] = subs.elementAt (r);\r
-}\r
-subs.removeAllElements ();\r
-return res;\r
-}}if (onlyIfMatches) {\r
-return null;\r
-}}if (idstring.indexOf ("|") > -1) {\r
-idstring = idstring.substring (idstring.lastIndexOf ("|") + 1);\r
-}return  Clazz.newArray (-1, [idstring, this.url_prefix + idstring + this.url_suffix]);\r
-} else {\r
-return  Clazz.newArray (-1, ["", this.url_prefix]);\r
-}}, "~S,~B");\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-return this.label + "|" + this.url_prefix + (this.dynamic ? ("$SEQUENCE_ID" + ((this.regexReplace != null) ? "=" + this.regexReplace + "=$" : "$")) : "") + ((this.url_suffix == null) ? "" : this.url_suffix);\r
-});\r
-Clazz.defineMethod (c$, "isDynamic", \r
-function () {\r
-return this.dynamic;\r
-});\r
-Clazz.defineMethod (c$, "setLabel", \r
-function (newlabel) {\r
-this.label = newlabel;\r
-}, "~S");\r
-});\r
+Clazz.declarePackage ("jalview.util");
+Clazz.load (null, "jalview.util.UrlLink", ["jalview.jsdev.RegExp", "java.util.Vector"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.url_suffix = null;
+this.url_prefix = null;
+this.target = null;
+this.label = null;
+this.regexReplace = null;
+this.dynamic = false;
+this.invalidMessage = null;
+Clazz.instantialize (this, arguments);
+}, jalview.util, "UrlLink");
+Clazz.makeConstructor (c$, 
+function (link) {
+var sep = link.indexOf ("|");
+var psqid = link.indexOf ("$SEQUENCE_ID");
+if (psqid > -1) {
+this.dynamic = true;
+var p = sep;
+do {
+sep = p;
+p = link.indexOf ("|", sep + 1);
+} while (p > sep && p < psqid);
+this.label = link.substring (0, sep);
+if (this.label.indexOf ("|") > -1) {
+this.target = this.label.substring (0, this.label.indexOf ("|"));
+} else if (this.label.indexOf (" ") > 2) {
+this.target = this.label.substring (0, this.label.indexOf (" "));
+} else {
+this.target = this.label;
+}this.url_prefix = link.substring (sep + 1, psqid);
+if (link.indexOf ("$SEQUENCE_ID=/") == psqid && (p = link.indexOf ("/=$", psqid + 14)) > psqid + 14) {
+this.url_suffix = link.substring (p + 3);
+this.regexReplace = link.substring (psqid + 14, p);
+try {
+var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/");
+if (rg == null) {
+this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n";
+}} catch (e) {
+if (Clazz.exceptionOf (e, Exception)) {
+this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n";
+} else {
+throw e;
+}
+}
+} else {
+this.regexReplace = null;
+if (link.indexOf ("$SEQUENCE_ID$") == psqid) {
+this.url_suffix = link.substring (psqid + 13);
+this.regexReplace = null;
+} else {
+this.invalidMessage = "Warning: invalid regex structure for URL link : " + link;
+}}} else {
+this.target = link.substring (0, sep);
+this.label = link.substring (0, sep = link.lastIndexOf ("|"));
+this.url_prefix = link.substring (sep + 1);
+this.regexReplace = null;
+this.url_suffix = null;
+}}, "~S");
+Clazz.defineMethod (c$, "getUrl_suffix", 
+function () {
+return this.url_suffix;
+});
+Clazz.defineMethod (c$, "getUrl_prefix", 
+function () {
+return this.url_prefix;
+});
+Clazz.defineMethod (c$, "getTarget", 
+function () {
+return this.target;
+});
+Clazz.defineMethod (c$, "getLabel", 
+function () {
+return this.label;
+});
+Clazz.defineMethod (c$, "getRegexReplace", 
+function () {
+return this.regexReplace;
+});
+Clazz.defineMethod (c$, "getInvalidMessage", 
+function () {
+return this.invalidMessage;
+});
+Clazz.defineMethod (c$, "isValid", 
+function () {
+return this.invalidMessage == null;
+});
+Clazz.defineMethod (c$, "makeUrls", 
+function (idstring, onlyIfMatches) {
+if (this.dynamic) {
+if (this.regexReplace != null) {
+var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/");
+if (rg.search (idstring)) {
+var ns = rg.numSubs ();
+if (ns == 0) {
+return  Clazz.newArray (-1, [rg.stringMatchedI (ns), this.url_prefix + rg.stringMatched () + this.url_suffix]);
+} else {
+for (var s = 0; s <= rg.numSubs (); s++) {
+System.err.println ("Sub " + s + " : " + rg.matchedFromI (s) + " : " + rg.matchedToI (s) + " : '" + rg.stringMatchedI (s) + "'");
+}
+var subs =  new java.util.Vector ();
+var s = 0;
+while (s <= ns) {
+if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) {
+var r = s + 1;
+var mtch = "";
+while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) {
+if (rg.matchedFromI (r) > -1) {
+mtch += rg.stringMatchedI (r);
+}r++;
+}
+if (mtch.length > 0) {
+subs.addElement (mtch);
+subs.addElement (this.url_prefix + mtch + this.url_suffix);
+}s = r;
+} else {
+if (rg.matchedFromI (s) > -1) {
+subs.addElement (rg.stringMatchedI (s));
+subs.addElement (this.url_prefix + rg.stringMatchedI (s) + this.url_suffix);
+}s++;
+}}
+var res =  new Array (subs.size ());
+for (var r = 0, rs = subs.size (); r < rs; r++) {
+res[r] = subs.elementAt (r);
+}
+subs.removeAllElements ();
+return res;
+}}if (onlyIfMatches) {
+return null;
+}}if (idstring.indexOf ("|") > -1) {
+idstring = idstring.substring (idstring.lastIndexOf ("|") + 1);
+}return  Clazz.newArray (-1, [idstring, this.url_prefix + idstring + this.url_suffix]);
+} else {
+return  Clazz.newArray (-1, ["", this.url_prefix]);
+}}, "~S,~B");
+Clazz.overrideMethod (c$, "toString", 
+function () {
+return this.label + "|" + this.url_prefix + (this.dynamic ? ("$SEQUENCE_ID" + ((this.regexReplace != null) ? "=" + this.regexReplace + "=$" : "$")) : "") + ((this.url_suffix == null) ? "" : this.url_suffix);
+});
+Clazz.defineMethod (c$, "isDynamic", 
+function () {
+return this.dynamic;
+});
+Clazz.defineMethod (c$, "setLabel", 
+function (newlabel) {
+this.label = newlabel;
+}, "~S");
+});