2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.SequenceI;
25 import java.util.Hashtable;
27 import com.stevesoft.pat.Regex;
30 * This class is not implemented because Preferences never puts anything in
36 public class GroupUrlLink
38 @SuppressWarnings("serial")
39 public class UrlStringTooLongException extends Exception
41 public UrlStringTooLongException(int lng)
49 public String toString()
51 return "Generated url is estimated to be too long (" + urlLength
57 * Helper class based on the UrlLink class which enables URLs to be
58 * constructed from sequences or IDs associated with a group of sequences. URL
59 * definitions consist of a pipe separated string containing a <label>|<url
60 * construct>|<separator character>[|<sequence separator character>]. The url
61 * construct includes regex qualified tokens which are replaced with seuqence
62 * IDs ($SEQUENCE_IDS$) and/or seuqence regions ($SEQUENCES$) that are
63 * extracted from the group. See <code>UrlLink</code> for more information
64 * about the approach, and the original implementation. Documentation to come.
65 * Note - groupUrls can be very big!
67 private String url_prefix, target, label;
70 * these are all filled in order of the occurence of each token in the url
73 private String url_suffix[], separators[], regexReplace[];
75 private String invalidMessage = null;
78 * position of each token (which can appear once only) in the url
83 * contains tokens in the order they appear in the URL template.
85 private String[] mtch;
88 * tokens that can be replaced in the URL.
90 private static final String[] tokens = new String[] { "SEQUENCEIDS",
91 "SEQUENCES", "DATASETID" };
94 // * test for GroupURLType bitfield (with default tokens)
96 // private static final int SEQUENCEIDS = 1;
99 // * test for GroupURLType bitfield (with default tokens)
101 // private static final int SEQUENCES = 2;
104 // * test for GroupURLType bitfield (with default tokens)
106 // private static final int DATASETID = 4;
108 // private int idseg = -1, seqseg = -1;
112 * called by PopupMenu.buildGroupURLMenu()
114 * parse the given linkString of the form '<label>|<url>|separator
115 * char[|optional sequence separator char]' into parts. url may contain a
116 * string $SEQUENCEIDS<=optional regex=>$ where <=optional regex=> must be of
117 * the form =/<perl style regex>/=$ or $SEQUENCES<=optional regex=>$ or
118 * $SEQUENCES<=optional regex=>$.
122 public GroupUrlLink(String link)
124 int sep = link.indexOf("|");
125 segs = new int[tokens.length];
127 for (int i = 0; i < segs.length; i++)
129 if ((segs[i] = link.indexOf("$" + tokens[i])) > -1)
134 // expect at least one token
137 invalidMessage = "Group URL string must contain at least one of ";
138 for (int i = 0; i < segs.length; i++)
140 invalidMessage += " '$" + tokens[i] + "[=/regex=/]$'";
145 int[] ptok = new int[ntoks + 1];
146 String[] tmtch = new String[ntoks + 1];
147 mtch = new String[ntoks];
148 for (int i = 0, t = 0; i < segs.length; i++)
153 tmtch[t++] = tokens[i];
156 ptok[ntoks] = link.length();
157 tmtch[ntoks] = "$$$$$$$$$";
158 jalview.util.QuickSort.sort(ptok, tmtch);
159 for (int i = 0; i < ntoks; i++)
161 mtch[i] = tmtch[i]; // TODO: check order is ascending
164 * replaces the specific code below {}; if (psqids > -1 && pseqs > -1) { if
165 * (psqids > pseqs) { idseg = 1; seqseg = 0;
167 * ptok = new int[] { pseqs, psqids, link.length() }; mtch = new String[] {
168 * "$SEQUENCES", "$SEQUENCEIDS" }; } else { idseg = 0; seqseg = 1; ptok =
169 * new int[] { psqids, pseqs, link.length() }; mtch = new String[] {
170 * "$SEQUENCEIDS", "$SEQUENCES" }; } } else { if (psqids != -1) { idseg = 0;
171 * ptok = new int[] { psqids, link.length() }; mtch = new String[] {
172 * "$SEQUENCEIDS" }; } else { seqseg = 0; ptok = new int[] { pseqs,
173 * link.length() }; mtch = new String[] { "$SEQUENCES" }; } }
177 // first get the label and target part before the first |
181 p = link.indexOf("|", sep + 1);
182 } while (p > sep && p < ptok[0]);
183 // Assuming that the URL itself does not contain any '|' symbols
184 // sep now contains last pipe symbol position prior to any regex symbols
185 label = link.substring(0, sep);
186 if (label.indexOf("|") > -1)
188 // | terminated database name / www target at start of Label
189 target = label.substring(0, label.indexOf("|"));
191 else if (label.indexOf(" ") > 2)
193 // space separated Label - matches database name
194 target = label.substring(0, label.indexOf(" "));
200 // Now Parse URL : Whole URL string first
201 url_prefix = link.substring(sep + 1, ptok[0]);
202 url_suffix = new String[mtch.length];
203 regexReplace = new String[mtch.length];
204 // and loop through tokens
205 for (int pass = 0; pass < mtch.length; pass++)
207 int mlength = 3 + mtch[pass].length();
208 if (link.indexOf("$" + mtch[pass] + "=/") == ptok[pass] && (p = link
209 .indexOf("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength)
211 // Extract Regex and suffix
212 if (ptok[pass + 1] < p + 3)
214 // tokens are not allowed inside other tokens - e.g. inserting a
215 // $sequences$ into the regex match for the sequenceid
216 invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $"
217 + mtch[pass] + " regex with a '/=$' ?";
220 url_suffix[pass] = link.substring(p + 3, ptok[pass + 1]);
221 regexReplace[pass] = link.substring(ptok[pass] + mlength, p);
224 Regex rg = Platform.newRegexPerl("/" + regexReplace[pass] + "/");
227 invalidMessage = "Invalid Regular Expression : '"
228 + regexReplace[pass] + "'\n";
230 } catch (Exception e)
232 invalidMessage = "Invalid Regular Expression : '"
233 + regexReplace[pass] + "'\n";
238 regexReplace[pass] = null;
239 // verify format is really correct.
240 if ((p = link.indexOf("$" + mtch[pass] + "$")) == ptok[pass])
242 url_suffix[pass] = link.substring(p + mtch[pass].length() + 2,
247 invalidMessage = "Warning: invalid regex structure (after '"
248 + mtch[0] + "') for URL link : " + link;
253 separators = new String[url_suffix.length];
254 String suffices = url_suffix[url_suffix.length - 1], lastsep = ",";
255 // have a look in the last suffix for any more separators.
256 while ((p = suffices.indexOf('|')) > -1)
258 separators[pass] = suffices.substring(p + 1);
261 // trim the original suffix string
262 url_suffix[url_suffix.length - 1] = suffices.substring(0, p);
266 lastsep = (separators[pass - 1] = separators[pass - 1].substring(0,
269 suffices = separators[pass];
274 lastsep = separators[pass - 1];
276 // last separator is always used for all the remaining separators
277 while (pass < separators.length)
279 separators[pass++] = lastsep;
284 * @return the url_suffix
286 public String getUrl_suffix()
288 return url_suffix[url_suffix.length - 1];
293 * called by PopupMenu.addShowLink()
295 * @return the url_prefix
297 public String getUrl_prefix()
303 * called by PopupMenu.buildGroupURLMenu()
307 public String getTarget()
314 * called by PopupMenu.buildGroupURLMenu()
318 public String getLabel()
325 * called by PopupMenu.buildGroupURLMenu()
327 * @return the invalidMessage
329 public String getInvalidMessage()
331 return invalidMessage;
335 * called by PopupMenu.buildGroupURLMenu()
337 * Check if URL string was parsed properly.
339 * @return boolean - if false then <code>getInvalidMessage</code> returns an
342 public boolean isValid()
344 return invalidMessage == null;
349 * called by PopupMenu.buildGroupURLMenu()
351 * This method is never called, because PopupMenu.buildGroupMenu() is never
352 * called. It relates to the popup menu for the idPanel.
357 * @param onlyIfMatches
358 * @return URL stub objects ready to pass to constructFrom in the form of
359 * Object[] { int[], boolean[], Hashtable<String, String[]>,
361 * @throws UrlStringTooLongException
363 public Object[] makeUrlStubs(String[] ids, String[] seqstr, String string,
364 boolean onlyIfMatches) throws UrlStringTooLongException
366 Hashtable<String, String[]> rstrings = replacementArgs(ids, seqstr,
368 boolean createFullURL = false;
369 Object[] stubs = makeUrlsIf(createFullURL, rstrings, onlyIfMatches);
370 // stubs is just { int[] boolean[] }
371 return stubs == null ? null
373 { stubs[0], stubs[1], rstrings,
375 { onlyIfMatches } }; // int[] boolean[] Hashtable boolean[]
379 * gathers input into a hashtable
386 private Hashtable<String, String[]> replacementArgs(String[] idstrings,
387 String[] seqstrings, String dsstring)
389 Hashtable<String, String[]> rstrings = new Hashtable<>();
390 rstrings.put(tokens[0], idstrings);
391 rstrings.put(tokens[1], seqstrings);
392 rstrings.put(tokens[2], new String[] { dsstring });
393 if (idstrings.length != seqstrings.length)
395 throw new Error(MessageManager.getString(
396 "error.idstring_seqstrings_only_one_per_sequence"));
402 * Called from PopupMenu.addShowLink action listener
404 * generate the URL for the given URL stub object array returned from
408 * Object[] { int[] { number of matches seqs }, boolean[] { which
409 * matched }, (if createFullUrl also has StringBuffer[] { segment
410 * generated from inputs that is used in URL }, String[] { url })}
412 * @throws UrlStringTooLongException
414 @SuppressWarnings("unchecked")
415 public String constructFrom(Object[] stubs)
416 throws UrlStringTooLongException
419 // int[] { number of matches seqs },
420 // boolean[] { which matched }
423 boolean createFullURL = true;
424 Hashtable<String, String[]> repstrings = (Hashtable<String, String[]>) stubs[2];
425 boolean onlyIfMatches = ((boolean[]) stubs[3])[0];
426 String url = ((String[]) makeUrlsIf(createFullURL, repstrings,
427 onlyIfMatches)[3])[0];
432 * conditionally generate urls or stubs for a given input.
434 * @param createFullUrl
435 * set to false if you only want to test if URLs would be generated.
437 * @param onlyIfMatches
438 * @return null if no url is generated. Object[] { int[] { number of matches
439 * seqs }, boolean[] { which matched }, (if createFullUrl also has
440 * StringBuffer[] { segment generated from inputs that is used in URL
441 * }, String[] { url })}
442 * @throws UrlStringTooLongException
444 private Object[] makeUrlsIf(boolean createFullUrl,
445 Hashtable<String, String[]> repstrings,
446 boolean onlyIfMatches) throws UrlStringTooLongException
450 // prepare string arrays in correct order to be assembled into URL input
451 String[][] idseq = new String[mtch.length][]; // indexed by pass
452 int mins = 0, maxs = 0; // allowed two values, 1 or n-sequences.
453 for (int i = 0; i < mtch.length; i++)
455 idseq[i] = repstrings.get(mtch[i]);
456 if (idseq[i].length >= 1)
458 if (mins == 0 && idseq[i].length == 1)
464 maxs = idseq[i].length;
468 if (maxs != idseq[i].length)
470 throw new Error(MessageManager.formatMessage(
471 "error.cannot_have_mixed_length_replacement_vectors",
474 Integer.valueOf(idseq[i].length).toString(),
475 Integer.valueOf(maxs).toString() }));
481 throw new Error(MessageManager.getString(
482 "error.cannot_have_zero_length_vector_replacement_strings"));
485 // iterate through input, collating segments to be inserted into url
486 StringBuffer matched[] = new StringBuffer[idseq.length];
487 // and precompile regexes
488 Regex[] rgxs = new Regex[matched.length];
489 for (pass = 0; pass < matched.length; pass++)
491 matched[pass] = new StringBuffer();
492 if (regexReplace[pass] != null)
494 rgxs[pass] = Platform.newRegexPerl("/" + regexReplace[pass] + "/");
501 // tot up the invariant lengths for this url
502 int urllength = url_prefix.length();
503 for (pass = 0; pass < matched.length; pass++)
505 urllength += url_suffix[pass].length();
508 // flags to record which of the input sequences were actually used to
511 boolean[] thismatched = new boolean[maxs];
513 for (int sq = 0; sq < maxs; sq++)
515 // initialise flag for match
516 thismatched[sq] = false;
517 StringBuffer[] thematches = new StringBuffer[rgxs.length];
518 for (pass = 0; pass < rgxs.length; pass++)
520 thematches[pass] = new StringBuffer(); // initialise - in case there are
523 // if a regex is provided, then it must match for all sequences in all
524 // tokens for it to be considered.
525 if (idseq[pass].length <= sq)
527 // no more replacement strings to try for this token
530 if (rgxs[pass] != null)
532 com.stevesoft.pat.Regex rg = rgxs[pass];
534 // concatenate all matches of re in the given string!
535 while (rg.searchFrom(idseq[pass][sq], rematchat))
537 rematchat = rg.matchedTo();
538 thismatched[sq] |= true;
539 urllength += rg.charsMatched(); // count length
540 if ((urllength + 32) > Platform.getMaxCommandLineLength())
542 throw new UrlStringTooLongException(urllength);
547 continue; // don't bother making the URL replacement text.
549 // do we take the cartesian products of the substituents ?
550 int ns = rg.numSubs();
553 thematches[pass].append(rg.stringMatched());// take whole regex
556 * else if (ns==1) { // take only subgroup match return new String[]
557 * { rg.stringMatched(1), url_prefix+rg.stringMatched(1)+url_suffix
560 // deal with multiple submatch case - for moment we do the simplest
561 // - concatenate the matched regions, instead of creating a complete
562 // list for each alternate match over all sequences.
563 // TODO: specify a 'replace pattern' - next refinement
568 * for (int s = 0; s <= rg.numSubs(); s++) {
569 * System.err.println("Sub " + s + " : " + rg.matchedFrom(s) +
570 * " : " + rg.matchedTo(s) + " : '" + rg.stringMatched(s) + "'");
573 // try to collate subgroup matches
574 StringBuffer subs = new StringBuffer();
575 // have to loop through submatches, collating them at top level
580 if (s + 1 <= ns && rg.matchedTo(s) > -1
581 && rg.matchedTo(s + 1) > -1
582 && rg.matchedTo(s + 1) < rg.matchedTo(s))
584 // s is top level submatch. search for submatches enclosed by
587 StringBuffer rmtch = new StringBuffer();
588 while (r <= ns && rg.matchedTo(r) <= rg.matchedTo(s))
590 if (rg.matchedFrom(r) > -1)
592 rmtch.append(rg.stringMatched(r));
596 if (rmtch.length() > 0)
598 subs.append(rmtch); // simply concatenate
604 if (rg.matchedFrom(s) > -1)
606 subs.append(rg.stringMatched(s)); // concatenate
611 thematches[pass].append(subs);
617 // are we only supposed to take regex matches ?
620 thismatched[sq] |= true;
621 urllength += idseq[pass][sq].length(); // tot up length
624 thematches[pass] = new StringBuffer(idseq[pass][sq]); // take
627 // regardless - probably not a
630 * TODO: do some boilerplate trimming of the fields to make them
631 * sensible e.g. trim off any 'prefix' in the id string (see
632 * UrlLink for the below) - pre 2.4 Jalview behaviour if
633 * (idstring.indexOf("|") > -1) { idstring =
634 * idstring.substring(idstring.lastIndexOf("|") + 1); }
642 // check if we are going to add this sequence's results ? all token
643 // replacements must be valid for this to happen!
644 // (including single value replacements - eg. dataset name)
649 for (pass = 0; pass < matched.length; pass++)
651 if (idseq[pass].length > 1 && matched[pass].length() > 0)
653 matched[pass].append(separators[pass]);
655 matched[pass].append(thematches[pass]);
661 // finally, if any sequences matched, then form the URL and return
662 if (seqsmatched == 0 || (createFullUrl && matched[0].length() == 0))
664 // no matches - no url generated
667 // check if we are beyond the feasible command line string limit for this
669 if ((urllength + 32) > Platform.getMaxCommandLineLength())
671 throw new UrlStringTooLongException(urllength);
675 // just return the essential info about what the URL would be generated
677 return new Object[] { new int[] { seqsmatched }, thismatched // boolean[]
680 // otherwise, create the URL completely.
682 StringBuffer submiturl = new StringBuffer();
683 submiturl.append(url_prefix);
684 for (pass = 0; pass < matched.length; pass++)
686 submiturl.append(matched[pass]);
687 if (url_suffix[pass] != null)
689 submiturl.append(url_suffix[pass]);
694 return new Object[] { new int[] { seqsmatched }, thismatched, // boolean[]
695 matched, // StringBuffer[]
697 { submiturl.toString() } };
702 * Called by PopupMenu.addShowLinks()
705 * @return number of distinct sequence (id or seuqence) replacements predicted
708 public int getNumberInvolved(Object[] urlstub)
710 return ((int[]) urlstub[0])[0]; // returns seqsmatched from
711 // makeUrlsIf(false,...)
715 * called by PopupMenu.buildGroupURLMenu()
717 * get token types present in this url as a bitfield indicating presence of
718 * each token from tokens (LSB->MSB).
720 * @return groupURL class as integer
722 public int getGroupURLType()
725 for (int pass = 0; pass < tokens.length; pass++)
727 for (int i = 0; i < mtch.length; i++)
729 if (mtch[i].equals(tokens[pass]))
739 * called by PopupMenu.buildGroupURLMenu()
741 * covenience method to generate the id and sequence string vector from a set
742 * of seuqences using each sequence's getName() and getSequenceAsString()
746 * @return String[][] {{sequence ids},{sequence strings}}
748 public static String[][] formStrings(SequenceI[] seqs)
750 String[][] idset = new String[2][seqs.length];
751 for (int i = 0; i < seqs.length; i++)
753 idset[0][i] = seqs[i].getName();
754 idset[1][i] = seqs[i].getSequenceAsString();
759 // commented out test code
766 // public static void main(String argv[])
768 // // note - JAL-1383 - these services are all dead
769 // String[] links = new String[] {
770 // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
771 // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCES$&inputType=1|,",
772 // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,",
773 // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
774 // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
775 // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
777 // Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([a-zA-Z]+)/=$&inputType=1|,",
779 // Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/[A-Za-z]+/=$&inputType=1|,"
782 // http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
783 // * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
784 // * linkInDatasetFromPRIDE
788 // SequenceI[] seqs = new SequenceI[] {
789 // new Sequence("StupidLabel:gi|9234|pdb|102L|A",
790 // "asdiasdpasdpadpwpadasdpaspdw"), };
791 // String[][] seqsandids = formStrings(seqs);
792 // for (int i = 0; i < links.length; i++)
794 // GroupUrlLink ul = new GroupUrlLink(links[i]);
797 // System.out.println("\n\n\n");
798 // System.out.println(
799 // "Link " + i + " " + links[i] + " : " + ul.toString());
800 // System.out.println(" pref : " + ul.getUrl_prefix());
801 // System.out.println(" IdReplace : " + ul.getIDRegexReplace());
802 // System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
803 // System.out.println(" Suffixes : " + ul.getUrl_suffix());
805 // System.out.println(
806 // "<insert input id and sequence strings here> Without onlyIfMatches:");
810 // urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
812 // testUrls(ul, seqsandids, urls);
813 // } catch (UrlStringTooLongException ex)
815 // System.out.println("too long exception " + ex);
817 // System.out.println(
818 // "<insert input id and sequence strings here> With onlyIfMatches set:");
821 // urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
823 // testUrls(ul, seqsandids, urls);
824 // } catch (UrlStringTooLongException ex)
826 // System.out.println("too long exception " + ex);
831 // System.err.println("Invalid URLLink : " + links[i] + " : "
832 // + ul.getInvalidMessage());
837 // * @return the sequence ID regexReplace
839 // private String getIDRegexReplace()
841 // String token = tokens[0];
842 // for (int i = 0; i < mtch.length; i++)
844 // if (segs[i] > -1 && mtch[i].equals(token))
846 // return regexReplace[i];
853 // * @return the sequence ID regexReplace
855 // private String getSeqRegexReplace()
857 // return _replaceFor(tokens[1]);
861 // * report stats about the generated url string given an input set
867 // private static void testUrls(GroupUrlLink ul, String[][] idstring,
873 // System.out.println("Created NO urls.");
877 // System.out.println("Created a url from " + ((int[]) url[0])[0]
878 // + "out of " + idstring[0].length + " sequences.");
879 // System.out.println("Sequences that did not match:");
880 // for (int sq = 0; sq < idstring[0].length; sq++)
882 // if (!((boolean[]) url[1])[sq])
884 // System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
885 // + idstring[1][sq]);
888 // System.out.println("Sequences that DID match:");
889 // for (int sq = 0; sq < idstring[0].length; sq++)
891 // if (((boolean[]) url[1])[sq])
893 // System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
894 // + idstring[1][sq]);
897 // System.out.println("The generated URL:");
898 // System.out.println(((String[]) url[3])[0]);
902 // public void setLabel(String newlabel)
904 // this.label = newlabel;
907 // * return one or more URL strings by applying regex to the given idstring
909 // * @param idstrings
910 // * array of id strings to pass to service
911 // * @param seqstrings
912 // * array of seq strings to pass to service
913 // * @param onlyIfMatches
914 // * - when true url strings are only made if regex is defined and
915 // * matches for all qualified tokens in groupURL - TODO: consider if
916 // * onlyIfMatches is really a useful parameter!
917 // * @return null or Object[] { int[] { number of seqs substituted},boolean[]
919 // * which seqs were substituted }, StringBuffer[] { substituted lists
920 // * for each token }, String[] { url } }
921 // * @throws UrlStringTooLongException
923 // private Object[] makeUrls(String[] idstrings, String[] seqstrings,
924 // String dsstring, boolean onlyIfMatches)
925 // throws UrlStringTooLongException
927 // Hashtable<String, String[]> rstrings = replacementArgs(idstrings,
928 // seqstrings, dsstring);
929 // return makeUrls(rstrings, onlyIfMatches);
934 // * @param repstrings
935 // * @param onlyIfMatches
936 // * @return Object[] {int[], boolean[], StringBuffer[], String[] }
937 // * @throws UrlStringTooLongException
939 // private Object[] makeUrls(Hashtable<String, String[]> repstrings,
940 // boolean onlyIfMatches)
941 // throws UrlStringTooLongException
943 // return makeUrlsIf(true, repstrings, onlyIfMatches);
948 public String toString()
950 StringBuffer result = new StringBuffer();
951 result.append(label + "|" + url_prefix);
953 for (r = 0; r < url_suffix.length; r++)
956 result.append(mtch[r]);
957 if (regexReplace[r] != null)
960 result.append(regexReplace[r]);
964 result.append(url_suffix[r]);
966 for (r = 0; r < separators.length; r++)
969 result.append(separators[r]);
971 return result.toString();