- }
- ptok[ntoks] = link.length();
- tmtch[ntoks] = "$$$$$$$$$";
- jalview.util.QuickSort.sort(ptok, tmtch);
- for (int i = 0; i < ntoks; i++)
- {
- mtch[i] = tmtch[i]; // TODO: check order is ascending
- }
- /*
- * replaces the specific code below {}; if (psqids > -1 && pseqs > -1) { if
- * (psqids > pseqs) { idseg = 1; seqseg = 0;
- *
- * ptok = new int[] { pseqs, psqids, link.length() }; mtch = new String[] {
- * "$SEQUENCES", "$SEQUENCEIDS" }; } else { idseg = 0; seqseg = 1; ptok =
- * new int[] { psqids, pseqs, link.length() }; mtch = new String[] {
- * "$SEQUENCEIDS", "$SEQUENCES" }; } } else { if (psqids != -1) { idseg = 0;
- * ptok = new int[] { psqids, link.length() }; mtch = new String[] {
- * "$SEQUENCEIDS" }; } else { seqseg = 0; ptok = new int[] { pseqs,
- * link.length() }; mtch = new String[] { "$SEQUENCES" }; } }
- */
-
- int p = sep;
- // first get the label and target part before the first |
- do
- {
- sep = p;
- p = link.indexOf("|", sep + 1);
- } while (p > sep && p < ptok[0]);
- // Assuming that the URL itself does not contain any '|' symbols
- // sep now contains last pipe symbol position prior to any regex symbols
- label = link.substring(0, sep);
- if (label.indexOf("|") > -1)
- {
- // | terminated database name / www target at start of Label
- target = label.substring(0, label.indexOf("|"));
- }
- else if (label.indexOf(" ") > 2)
- {
- // space separated Label - matches database name
- target = label.substring(0, label.indexOf(" "));
- }
- else
- {
- target = label;
- }
- // Now Parse URL : Whole URL string first
- url_prefix = link.substring(sep + 1, ptok[0]);
- url_suffix = new String[mtch.length];
- regexReplace = new String[mtch.length];
- // and loop through tokens
- for (int pass = 0; pass < mtch.length; pass++)
- {
- int mlength = 3 + mtch[pass].length();
- if (link.indexOf("$" + mtch[pass] + "=/") == ptok[pass]
- && (p = link.indexOf("/=$", ptok[pass] + mlength)) > ptok[pass]
- + mlength)