X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Futil%2FGroupUrlLink.js;h=732a41bd8aa38c23e15055b0a07882f17614ac66;hp=b5b24a6d1025fb392892ba222773846be2297b2d;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/util/GroupUrlLink.js b/site/j2s/jalview/util/GroupUrlLink.js index b5b24a6..732a41b 100644 --- a/site/j2s/jalview/util/GroupUrlLink.js +++ b/site/j2s/jalview/util/GroupUrlLink.js @@ -1,363 +1,363 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.lang.Exception"], "jalview.util.GroupUrlLink", ["jalview.jsdev.RegExp", "jalview.util.MessageManager", "$.Platform", "$.QuickSort", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.util.GroupUrlLink.UrlStringTooLongException")) { -jalview.util.GroupUrlLink.$GroupUrlLink$UrlStringTooLongException$ (); -} -this.url_prefix = null; -this.target = null; -this.label = null; -this.url_suffix = null; -this.separators = null; -this.regexReplace = null; -this.invalidMessage = null; -this.segs = null; -this.mtch = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "GroupUrlLink"); -Clazz.makeConstructor (c$, -function (link) { -var sep = link.indexOf ("|"); -this.segs = Clazz.newIntArray (jalview.util.GroupUrlLink.tokens.length, 0); -var ntoks = 0; -for (var i = 0; i < this.segs.length; i++) { -if ((this.segs[i] = link.indexOf ("$" + jalview.util.GroupUrlLink.tokens[i])) > -1) { -ntoks++; -}} -if (ntoks == 0) { -this.invalidMessage = "Group URL string must contain at least one of "; -for (var i = 0; i < this.segs.length; i++) { -this.invalidMessage += " '$" + jalview.util.GroupUrlLink.tokens[i] + "[=/regex=/]$'"; -} -return; -}var ptok = Clazz.newIntArray (ntoks + 1, 0); -var tmtch = new Array (ntoks + 1); -this.mtch = new Array (ntoks); -for (var i = 0, t = 0; i < this.segs.length; i++) { -if (this.segs[i] > -1) { -ptok[t] = this.segs[i]; -tmtch[t++] = jalview.util.GroupUrlLink.tokens[i]; -}} -ptok[ntoks] = link.length; -tmtch[ntoks] = "$$$$$$$$$"; -jalview.util.QuickSort.sortInt (ptok, tmtch); -for (var i = 0; i < ntoks; i++) { -this.mtch[i] = tmtch[i]; -} -var p = sep; -do { -sep = p; -p = link.indexOf ("|", sep + 1); -} while (p > sep && p < ptok[0]); -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, ptok[0]); -this.url_suffix = new Array (this.mtch.length); -this.regexReplace = new Array (this.mtch.length); -for (var pass = 0; pass < this.mtch.length; pass++) { -var mlength = 3 + this.mtch[pass].length; -if (link.indexOf ("$" + this.mtch[pass] + "=/") == ptok[pass] && (p = link.indexOf ("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength) { -if (ptok[pass + 1] < p + 3) { -this.invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $" + this.mtch[pass] + " regex with a '/=$' ?"; -return; -}this.url_suffix[pass] = link.substring (p + 3, ptok[pass + 1]); -this.regexReplace[pass] = link.substring (ptok[pass] + mlength, p); -try { -var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); -if (rg == null) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; -} else { -throw e; -} -} -} else { -this.regexReplace[pass] = null; -if ((p = link.indexOf ("$" + this.mtch[pass] + "$")) == ptok[pass]) { -this.url_suffix[pass] = link.substring (p + this.mtch[pass].length + 2, ptok[pass + 1]); -} else { -this.invalidMessage = "Warning: invalid regex structure (after '" + this.mtch[0] + "') for URL link : " + link; -}}} -var pass = 0; -this.separators = new Array (this.url_suffix.length); -var suffices = this.url_suffix[this.url_suffix.length - 1]; -var lastsep = ","; -while ((p = suffices.indexOf ('|')) > -1) { -this.separators[pass] = suffices.substring (p + 1); -if (pass == 0) { -this.url_suffix[this.url_suffix.length - 1] = suffices.substring (0, p); -} else { -lastsep = (this.separators[pass - 1] = this.separators[pass - 1].substring (0, p)); -}suffices = this.separators[pass]; -pass++; -} -if (pass > 0) { -lastsep = this.separators[pass - 1]; -}while (pass < this.separators.length) { -this.separators[pass++] = lastsep; -} -}, "~S"); -Clazz.defineMethod (c$, "getUrl_suffix", -function () { -return this.url_suffix[this.url_suffix.length - 1]; -}); -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$, "getIDRegexReplace", -function () { -return this._replaceFor (jalview.util.GroupUrlLink.tokens[0]); -}); -Clazz.defineMethod (c$, "_replaceFor", - function (token) { -for (var i = 0; i < this.mtch.length; i++) { -if (this.segs[i] > -1 && this.mtch[i].equals (token)) { -return this.regexReplace[i]; -}} -return null; -}, "~S"); -Clazz.defineMethod (c$, "getSeqRegexReplace", -function () { -return this._replaceFor (jalview.util.GroupUrlLink.tokens[1]); -}); -Clazz.defineMethod (c$, "getInvalidMessage", -function () { -return this.invalidMessage; -}); -Clazz.defineMethod (c$, "isValid", -function () { -return this.invalidMessage == null; -}); -Clazz.defineMethod (c$, "makeUrls", -function (idstrings, seqstrings, dsstring, onlyIfMatches) { -var rstrings = this.replacementArgs (idstrings, seqstrings, dsstring); -return this.makeUrls (rstrings, onlyIfMatches); -}, "~A,~A,~S,~B"); -Clazz.defineMethod (c$, "replacementArgs", - function (idstrings, seqstrings, dsstring) { -var rstrings = new java.util.Hashtable (); -rstrings.put (jalview.util.GroupUrlLink.tokens[0], idstrings); -rstrings.put (jalview.util.GroupUrlLink.tokens[1], seqstrings); -rstrings.put (jalview.util.GroupUrlLink.tokens[2], Clazz.newArray (-1, [dsstring])); -if (idstrings.length != seqstrings.length) { -throw new Error (jalview.util.MessageManager.getString ("error.idstring_seqstrings_only_one_per_sequence")); -}return rstrings; -}, "~A,~A,~S"); -Clazz.defineMethod (c$, "makeUrls", -function (repstrings, onlyIfMatches) { -return this.makeUrlsIf (true, repstrings, onlyIfMatches); -}, "java.util.Hashtable,~B"); -Clazz.defineMethod (c$, "makeUrlStubs", -function (ids, seqstr, string, b) { -var rstrings = this.replacementArgs (ids, seqstr, string); -var stubs = this.makeUrlsIf (false, rstrings, b); -if (stubs != null) { -return Clazz.newArray (-1, [stubs[0], stubs[1], rstrings, Clazz.newBooleanArray (-1, [b])]); -}return null; -}, "~A,~A,~S,~B"); -Clazz.defineMethod (c$, "constructFrom", -function (stubs) { -var results = this.makeUrlsIf (true, stubs[2], (stubs[3])[0]); -return (results[3])[0]; -}, "~A"); -Clazz.defineMethod (c$, "makeUrlsIf", -function (createFullUrl, repstrings, onlyIfMatches) { -var pass = 0; -var idseq = new Array (this.mtch.length); -var mins = 0; -var maxs = 0; -for (var i = 0; i < this.mtch.length; i++) { -idseq[i] = repstrings.get (this.mtch[i]); -if (idseq[i].length >= 1) { -if (mins == 0 && idseq[i].length == 1) { -mins = 1; -}if (maxs < 2) { -maxs = idseq[i].length; -} else { -if (maxs != idseq[i].length) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.cannot_have_mixed_length_replacement_vectors", Clazz.newArray (-1, [(this.mtch[i]), Integer.$valueOf (idseq[i].length).toString (), Integer.$valueOf (maxs).toString ()]))); -}}} else { -throw new Error (jalview.util.MessageManager.getString ("error.cannot_have_zero_length_vector_replacement_strings")); -}} -var matched = new Array (idseq.length); -var rgxs = new Array (matched.length); -for (pass = 0; pass < matched.length; pass++) { -matched[pass] = new StringBuffer (); -if (this.regexReplace[pass] != null) { -rgxs[pass] = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); -} else { -rgxs[pass] = null; -}} -var urllength = this.url_prefix.length; -for (pass = 0; pass < matched.length; pass++) { -urllength += this.url_suffix[pass].length; -} -var thismatched = Clazz.newBooleanArray (maxs, false); -var seqsmatched = 0; -for (var sq = 0; sq < maxs; sq++) { -thismatched[sq] = false; -var thematches = new Array (rgxs.length); -for (pass = 0; pass < rgxs.length; pass++) { -thematches[pass] = new StringBuffer (); -if (idseq[pass].length <= sq) { -continue; -}if (rgxs[pass] != null) { -var rg = rgxs[pass]; -var rematchat = 0; -while (rg.searchFrom (idseq[pass][sq], rematchat)) { -rematchat = rg.matchedTo (); -thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); -urllength += rg.charsMatched (); -if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { -throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); -}if (!createFullUrl) { -continue; -}var ns = rg.numSubs (); -if (ns == 0) { -thematches[pass].append (rg.stringMatched ()); -} else { -var subs = new StringBuffer (); -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 rmtch = new StringBuffer (); -while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { -if (rg.matchedFromI (r) > -1) { -rmtch.append (rg.stringMatchedI (r)); -}r++; -} -if (rmtch.length () > 0) { -subs.append (rmtch); -}s = r; -} else { -if (rg.matchedFromI (s) > -1) { -subs.append (rg.stringMatchedI (s)); -}s++; -}} -thematches[pass].append (subs); -}} -} else { -if (!onlyIfMatches) { -thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); -urllength += idseq[pass][sq].length; -if (createFullUrl) { -thematches[pass] = new StringBuffer (idseq[pass][sq]); -}}}} -if (thismatched[sq]) { -if (createFullUrl) { -for (pass = 0; pass < matched.length; pass++) { -if (idseq[pass].length > 1 && matched[pass].length () > 0) { -matched[pass].append (this.separators[pass]); -}matched[pass].append (thematches[pass]); -} -}seqsmatched++; -}} -if (seqsmatched == 0 || (createFullUrl && matched[0].length () == 0)) { -return null; -}if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { -throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); -}if (!createFullUrl) { -return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched]); -}var submiturl = new StringBuffer (); -submiturl.append (this.url_prefix); -for (pass = 0; pass < matched.length; pass++) { -submiturl.append (matched[pass]); -if (this.url_suffix[pass] != null) { -submiturl.append (this.url_suffix[pass]); -}} -return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched, matched, Clazz.newArray (-1, [submiturl.toString ()])]); -}, "~B,java.util.Hashtable,~B"); -Clazz.defineMethod (c$, "getNumberInvolved", -function (urlstub) { -return (urlstub[0])[0]; -}, "~A"); -Clazz.defineMethod (c$, "getGroupURLType", -function () { -var r = 0; -for (var pass = 0; pass < jalview.util.GroupUrlLink.tokens.length; pass++) { -for (var i = 0; i < this.mtch.length; i++) { -if (this.mtch[i].equals (jalview.util.GroupUrlLink.tokens[pass])) { -r += 1 << pass; -}} -} -return r; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var result = new StringBuffer (); -result.append (this.label + "|" + this.url_prefix); -var r; -for (r = 0; r < this.url_suffix.length; r++) { -result.append ("$"); -result.append (this.mtch[r]); -if (this.regexReplace[r] != null) { -result.append ("=/"); -result.append (this.regexReplace[r]); -result.append ("/="); -}result.append ("$"); -result.append (this.url_suffix[r]); -} -for (r = 0; r < this.separators.length; r++) { -result.append ("|"); -result.append (this.separators[r]); -} -return result.toString (); -}); -c$.formStrings = Clazz.defineMethod (c$, "formStrings", -function (seqs) { -var idset = Clazz.newArray (2, seqs.length, null); -for (var i = 0; i < seqs.length; i++) { -idset[0][i] = seqs[i].getName (); -idset[1][i] = seqs[i].getSequenceAsString (); -} -return idset; -}, "~A"); -Clazz.defineMethod (c$, "setLabel", -function (newlabel) { -this.label = newlabel; -}, "~S"); -c$.$GroupUrlLink$UrlStringTooLongException$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.urlLength = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.GroupUrlLink, "UrlStringTooLongException", Exception); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.util.GroupUrlLink.UrlStringTooLongException, []); -this.urlLength = a; -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return "Generated url is estimated to be too long (" + this.urlLength + ")"; -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"tokens", null); -{ -if (jalview.util.GroupUrlLink.tokens == null) { -jalview.util.GroupUrlLink.tokens = Clazz.newArray (-1, ["SEQUENCEIDS", "SEQUENCES", "DATASETID"]); -}}Clazz.defineStatics (c$, -"SEQUENCEIDS", 1, -"SEQUENCES", 2, -"DATASETID", 4); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.lang.Exception"], "jalview.util.GroupUrlLink", ["jalview.jsdev.RegExp", "jalview.util.MessageManager", "$.Platform", "$.QuickSort", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.util.GroupUrlLink.UrlStringTooLongException")) { +jalview.util.GroupUrlLink.$GroupUrlLink$UrlStringTooLongException$ (); +} +this.url_prefix = null; +this.target = null; +this.label = null; +this.url_suffix = null; +this.separators = null; +this.regexReplace = null; +this.invalidMessage = null; +this.segs = null; +this.mtch = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "GroupUrlLink"); +Clazz.makeConstructor (c$, +function (link) { +var sep = link.indexOf ("|"); +this.segs = Clazz.newIntArray (jalview.util.GroupUrlLink.tokens.length, 0); +var ntoks = 0; +for (var i = 0; i < this.segs.length; i++) { +if ((this.segs[i] = link.indexOf ("$" + jalview.util.GroupUrlLink.tokens[i])) > -1) { +ntoks++; +}} +if (ntoks == 0) { +this.invalidMessage = "Group URL string must contain at least one of "; +for (var i = 0; i < this.segs.length; i++) { +this.invalidMessage += " '$" + jalview.util.GroupUrlLink.tokens[i] + "[=/regex=/]$'"; +} +return; +}var ptok = Clazz.newIntArray (ntoks + 1, 0); +var tmtch = new Array (ntoks + 1); +this.mtch = new Array (ntoks); +for (var i = 0, t = 0; i < this.segs.length; i++) { +if (this.segs[i] > -1) { +ptok[t] = this.segs[i]; +tmtch[t++] = jalview.util.GroupUrlLink.tokens[i]; +}} +ptok[ntoks] = link.length; +tmtch[ntoks] = "$$$$$$$$$"; +jalview.util.QuickSort.sortInt (ptok, tmtch); +for (var i = 0; i < ntoks; i++) { +this.mtch[i] = tmtch[i]; +} +var p = sep; +do { +sep = p; +p = link.indexOf ("|", sep + 1); +} while (p > sep && p < ptok[0]); +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, ptok[0]); +this.url_suffix = new Array (this.mtch.length); +this.regexReplace = new Array (this.mtch.length); +for (var pass = 0; pass < this.mtch.length; pass++) { +var mlength = 3 + this.mtch[pass].length; +if (link.indexOf ("$" + this.mtch[pass] + "=/") == ptok[pass] && (p = link.indexOf ("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength) { +if (ptok[pass + 1] < p + 3) { +this.invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $" + this.mtch[pass] + " regex with a '/=$' ?"; +return; +}this.url_suffix[pass] = link.substring (p + 3, ptok[pass + 1]); +this.regexReplace[pass] = link.substring (ptok[pass] + mlength, p); +try { +var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); +if (rg == null) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; +} else { +throw e; +} +} +} else { +this.regexReplace[pass] = null; +if ((p = link.indexOf ("$" + this.mtch[pass] + "$")) == ptok[pass]) { +this.url_suffix[pass] = link.substring (p + this.mtch[pass].length + 2, ptok[pass + 1]); +} else { +this.invalidMessage = "Warning: invalid regex structure (after '" + this.mtch[0] + "') for URL link : " + link; +}}} +var pass = 0; +this.separators = new Array (this.url_suffix.length); +var suffices = this.url_suffix[this.url_suffix.length - 1]; +var lastsep = ","; +while ((p = suffices.indexOf ('|')) > -1) { +this.separators[pass] = suffices.substring (p + 1); +if (pass == 0) { +this.url_suffix[this.url_suffix.length - 1] = suffices.substring (0, p); +} else { +lastsep = (this.separators[pass - 1] = this.separators[pass - 1].substring (0, p)); +}suffices = this.separators[pass]; +pass++; +} +if (pass > 0) { +lastsep = this.separators[pass - 1]; +}while (pass < this.separators.length) { +this.separators[pass++] = lastsep; +} +}, "~S"); +Clazz.defineMethod (c$, "getUrl_suffix", +function () { +return this.url_suffix[this.url_suffix.length - 1]; +}); +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$, "getIDRegexReplace", +function () { +return this._replaceFor (jalview.util.GroupUrlLink.tokens[0]); +}); +Clazz.defineMethod (c$, "_replaceFor", + function (token) { +for (var i = 0; i < this.mtch.length; i++) { +if (this.segs[i] > -1 && this.mtch[i].equals (token)) { +return this.regexReplace[i]; +}} +return null; +}, "~S"); +Clazz.defineMethod (c$, "getSeqRegexReplace", +function () { +return this._replaceFor (jalview.util.GroupUrlLink.tokens[1]); +}); +Clazz.defineMethod (c$, "getInvalidMessage", +function () { +return this.invalidMessage; +}); +Clazz.defineMethod (c$, "isValid", +function () { +return this.invalidMessage == null; +}); +Clazz.defineMethod (c$, "makeUrls", +function (idstrings, seqstrings, dsstring, onlyIfMatches) { +var rstrings = this.replacementArgs (idstrings, seqstrings, dsstring); +return this.makeUrls (rstrings, onlyIfMatches); +}, "~A,~A,~S,~B"); +Clazz.defineMethod (c$, "replacementArgs", + function (idstrings, seqstrings, dsstring) { +var rstrings = new java.util.Hashtable (); +rstrings.put (jalview.util.GroupUrlLink.tokens[0], idstrings); +rstrings.put (jalview.util.GroupUrlLink.tokens[1], seqstrings); +rstrings.put (jalview.util.GroupUrlLink.tokens[2], Clazz.newArray (-1, [dsstring])); +if (idstrings.length != seqstrings.length) { +throw new Error (jalview.util.MessageManager.getString ("error.idstring_seqstrings_only_one_per_sequence")); +}return rstrings; +}, "~A,~A,~S"); +Clazz.defineMethod (c$, "makeUrls", +function (repstrings, onlyIfMatches) { +return this.makeUrlsIf (true, repstrings, onlyIfMatches); +}, "java.util.Hashtable,~B"); +Clazz.defineMethod (c$, "makeUrlStubs", +function (ids, seqstr, string, b) { +var rstrings = this.replacementArgs (ids, seqstr, string); +var stubs = this.makeUrlsIf (false, rstrings, b); +if (stubs != null) { +return Clazz.newArray (-1, [stubs[0], stubs[1], rstrings, Clazz.newBooleanArray (-1, [b])]); +}return null; +}, "~A,~A,~S,~B"); +Clazz.defineMethod (c$, "constructFrom", +function (stubs) { +var results = this.makeUrlsIf (true, stubs[2], (stubs[3])[0]); +return (results[3])[0]; +}, "~A"); +Clazz.defineMethod (c$, "makeUrlsIf", +function (createFullUrl, repstrings, onlyIfMatches) { +var pass = 0; +var idseq = new Array (this.mtch.length); +var mins = 0; +var maxs = 0; +for (var i = 0; i < this.mtch.length; i++) { +idseq[i] = repstrings.get (this.mtch[i]); +if (idseq[i].length >= 1) { +if (mins == 0 && idseq[i].length == 1) { +mins = 1; +}if (maxs < 2) { +maxs = idseq[i].length; +} else { +if (maxs != idseq[i].length) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.cannot_have_mixed_length_replacement_vectors", Clazz.newArray (-1, [(this.mtch[i]), Integer.$valueOf (idseq[i].length).toString (), Integer.$valueOf (maxs).toString ()]))); +}}} else { +throw new Error (jalview.util.MessageManager.getString ("error.cannot_have_zero_length_vector_replacement_strings")); +}} +var matched = new Array (idseq.length); +var rgxs = new Array (matched.length); +for (pass = 0; pass < matched.length; pass++) { +matched[pass] = new StringBuffer (); +if (this.regexReplace[pass] != null) { +rgxs[pass] = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); +} else { +rgxs[pass] = null; +}} +var urllength = this.url_prefix.length; +for (pass = 0; pass < matched.length; pass++) { +urllength += this.url_suffix[pass].length; +} +var thismatched = Clazz.newBooleanArray (maxs, false); +var seqsmatched = 0; +for (var sq = 0; sq < maxs; sq++) { +thismatched[sq] = false; +var thematches = new Array (rgxs.length); +for (pass = 0; pass < rgxs.length; pass++) { +thematches[pass] = new StringBuffer (); +if (idseq[pass].length <= sq) { +continue; +}if (rgxs[pass] != null) { +var rg = rgxs[pass]; +var rematchat = 0; +while (rg.searchFrom (idseq[pass][sq], rematchat)) { +rematchat = rg.matchedTo (); +thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); +urllength += rg.charsMatched (); +if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { +throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); +}if (!createFullUrl) { +continue; +}var ns = rg.numSubs (); +if (ns == 0) { +thematches[pass].append (rg.stringMatched ()); +} else { +var subs = new StringBuffer (); +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 rmtch = new StringBuffer (); +while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { +if (rg.matchedFromI (r) > -1) { +rmtch.append (rg.stringMatchedI (r)); +}r++; +} +if (rmtch.length () > 0) { +subs.append (rmtch); +}s = r; +} else { +if (rg.matchedFromI (s) > -1) { +subs.append (rg.stringMatchedI (s)); +}s++; +}} +thematches[pass].append (subs); +}} +} else { +if (!onlyIfMatches) { +thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); +urllength += idseq[pass][sq].length; +if (createFullUrl) { +thematches[pass] = new StringBuffer (idseq[pass][sq]); +}}}} +if (thismatched[sq]) { +if (createFullUrl) { +for (pass = 0; pass < matched.length; pass++) { +if (idseq[pass].length > 1 && matched[pass].length () > 0) { +matched[pass].append (this.separators[pass]); +}matched[pass].append (thematches[pass]); +} +}seqsmatched++; +}} +if (seqsmatched == 0 || (createFullUrl && matched[0].length () == 0)) { +return null; +}if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { +throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); +}if (!createFullUrl) { +return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched]); +}var submiturl = new StringBuffer (); +submiturl.append (this.url_prefix); +for (pass = 0; pass < matched.length; pass++) { +submiturl.append (matched[pass]); +if (this.url_suffix[pass] != null) { +submiturl.append (this.url_suffix[pass]); +}} +return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched, matched, Clazz.newArray (-1, [submiturl.toString ()])]); +}, "~B,java.util.Hashtable,~B"); +Clazz.defineMethod (c$, "getNumberInvolved", +function (urlstub) { +return (urlstub[0])[0]; +}, "~A"); +Clazz.defineMethod (c$, "getGroupURLType", +function () { +var r = 0; +for (var pass = 0; pass < jalview.util.GroupUrlLink.tokens.length; pass++) { +for (var i = 0; i < this.mtch.length; i++) { +if (this.mtch[i].equals (jalview.util.GroupUrlLink.tokens[pass])) { +r += 1 << pass; +}} +} +return r; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var result = new StringBuffer (); +result.append (this.label + "|" + this.url_prefix); +var r; +for (r = 0; r < this.url_suffix.length; r++) { +result.append ("$"); +result.append (this.mtch[r]); +if (this.regexReplace[r] != null) { +result.append ("=/"); +result.append (this.regexReplace[r]); +result.append ("/="); +}result.append ("$"); +result.append (this.url_suffix[r]); +} +for (r = 0; r < this.separators.length; r++) { +result.append ("|"); +result.append (this.separators[r]); +} +return result.toString (); +}); +c$.formStrings = Clazz.defineMethod (c$, "formStrings", +function (seqs) { +var idset = Clazz.newArray (2, seqs.length, null); +for (var i = 0; i < seqs.length; i++) { +idset[0][i] = seqs[i].getName (); +idset[1][i] = seqs[i].getSequenceAsString (); +} +return idset; +}, "~A"); +Clazz.defineMethod (c$, "setLabel", +function (newlabel) { +this.label = newlabel; +}, "~S"); +c$.$GroupUrlLink$UrlStringTooLongException$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.urlLength = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.GroupUrlLink, "UrlStringTooLongException", Exception); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.util.GroupUrlLink.UrlStringTooLongException, []); +this.urlLength = a; +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return "Generated url is estimated to be too long (" + this.urlLength + ")"; +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"tokens", null); +{ +if (jalview.util.GroupUrlLink.tokens == null) { +jalview.util.GroupUrlLink.tokens = Clazz.newArray (-1, ["SEQUENCEIDS", "SEQUENCES", "DATASETID"]); +}}Clazz.defineStatics (c$, +"SEQUENCEIDS", 1, +"SEQUENCES", 2, +"DATASETID", 4); +});