/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.util;
import jalview.datamodel.SequenceI;
import java.util.Hashtable;
-import java.util.Vector;
public class GroupUrlLink
{
{
if (tokens == null)
{
- tokens = new String[]
- { "SEQUENCEIDS", "SEQUENCES", "DATASETID" };
+ tokens = new String[] { "SEQUENCEIDS", "SEQUENCES", "DATASETID" };
}
}
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)
+ if (link.indexOf("$" + mtch[pass] + "=/") == ptok[pass] && (p = link
+ .indexOf("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength)
{
// Extract Regex and suffix
if (ptok[pass + 1] < p + 3)
regexReplace[pass] = link.substring(ptok[pass] + mlength, p);
try
{
- com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex.perlCode("/"
- + regexReplace[pass] + "/");
+ com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex
+ .perlCode("/" + regexReplace[pass] + "/");
if (rg == null)
{
invalidMessage = "Invalid Regular Expression : '"
* @param dsstring
* @return
*/
- private Hashtable replacementArgs(String[] idstrings,
- String[] seqstrings, String dsstring)
+ private Hashtable replacementArgs(String[] idstrings, String[] seqstrings,
+ String dsstring)
{
Hashtable rstrings = new Hashtable();
rstrings.put(tokens[0], idstrings);
rstrings.put(tokens[1], seqstrings);
- rstrings.put(tokens[2], new String[]
- { dsstring });
+ rstrings.put(tokens[2], new String[] { dsstring });
if (idstrings.length != seqstrings.length)
{
- throw new Error(
- "idstrings and seqstrings contain one string each per sequence.");
+ throw new Error(MessageManager.getString(
+ "error.idstring_seqstrings_only_one_per_sequence"));
}
return rstrings;
}
* @return URL stub objects ready to pass to constructFrom
* @throws UrlStringTooLongException
*/
- public Object[] makeUrlStubs(String[] ids, String[] seqstr,
- String string, boolean b) throws UrlStringTooLongException
+ public Object[] makeUrlStubs(String[] ids, String[] seqstr, String string,
+ boolean b) throws UrlStringTooLongException
{
Hashtable rstrings = replacementArgs(ids, seqstr, string);
Object[] stubs = makeUrlsIf(false, rstrings, b);
if (stubs != null)
{
- return new Object[]
- { stubs[0], stubs[1], rstrings, new boolean[]
- { b } };
+ return new Object[] { stubs[0], stubs[1], rstrings,
+ new boolean[]
+ { b } };
}
// TODO Auto-generated method stub
return null;
* }, String[] { url })}
* @throws UrlStringTooLongException
*/
- protected Object[] makeUrlsIf(boolean createFullUrl,
- Hashtable repstrings, boolean onlyIfMatches)
- throws UrlStringTooLongException
+ protected Object[] makeUrlsIf(boolean createFullUrl, Hashtable repstrings,
+ boolean onlyIfMatches) throws UrlStringTooLongException
{
int pass = 0;
{
if (maxs != idseq[i].length)
{
- throw new Error(
- "Cannot have mixed length replacement vectors. Replacement vector for "
- + (mtch[i]) + " is " + idseq[i].length
- + " strings long, and have already seen a "
- + maxs + " length vector.");
+ throw new Error(MessageManager.formatMessage(
+ "error.cannot_have_mixed_length_replacement_vectors",
+ new String[]
+ { (mtch[i]),
+ Integer.valueOf(idseq[i].length).toString(),
+ Integer.valueOf(maxs).toString() }));
}
}
}
else
{
- throw new Error(
- "Cannot have zero length vector of replacement strings - either 1 value or n values.");
+ throw new Error(MessageManager.getString(
+ "error.cannot_have_zero_length_vector_replacement_strings"));
}
}
// iterate through input, collating segments to be inserted into url
matched[pass] = new StringBuffer();
if (regexReplace[pass] != null)
{
- rgxs[pass] = com.stevesoft.pat.Regex.perlCode("/"
- + regexReplace[pass] + "/");
+ rgxs[pass] = com.stevesoft.pat.Regex
+ .perlCode("/" + regexReplace[pass] + "/");
}
else
{
{
// just return the essential info about what the URL would be generated
// from
- return new Object[]
- { new int[]
- { seqsmatched }, thismatched };
+ return new Object[] { new int[] { seqsmatched }, thismatched };
}
// otherwise, create the URL completely.
}
}
- return new Object[]
- { new int[]
- { seqsmatched }, thismatched, matched, new String[]
- { submiturl.toString() } };
+ return new Object[] { new int[] { seqsmatched }, thismatched, matched,
+ new String[]
+ { submiturl.toString() } };
}
/**
public static void main(String argv[])
{
- String[] links = new String[]
- {
+ // note - JAL-1383 - these services are all dead
+ String[] links = new String[] {
"EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
"EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCES$&inputType=1|,",
"EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,",
"EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
"EnVision2 Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([a-zA-Z]+)/=$&inputType=1|,",
"EnVision2 Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/[A-Za-z]+/=$&inputType=1|,"
- /*
- * http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
- * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
- * linkInDatasetFromPRIDE
- */
+ /*
+ * http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
+ * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
+ * linkInDatasetFromPRIDE
+ */
};
- SequenceI[] seqs = new SequenceI[]
- { new Sequence("StupidLabel:gi|9234|pdb|102L|A",
- "asdiasdpasdpadpwpadasdpaspdw"), };
+ SequenceI[] seqs = new SequenceI[] {
+ new Sequence("StupidLabel:gi|9234|pdb|102L|A",
+ "asdiasdpasdpadpwpadasdpaspdw"), };
String[][] seqsandids = formStrings(seqs);
for (int i = 0; i < links.length; i++)
{
if (ul.isValid())
{
System.out.println("\n\n\n");
- System.out.println("Link " + i + " " + links[i] + " : "
- + ul.toString());
+ System.out.println(
+ "Link " + i + " " + links[i] + " : " + ul.toString());
System.out.println(" pref : " + ul.getUrl_prefix());
System.out.println(" IdReplace : " + ul.getIDRegexReplace());
System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
System.out.println(" Suffixes : " + ul.getUrl_suffix());
- System.out
- .println("<insert input id and sequence strings here> Without onlyIfMatches:");
+ System.out.println(
+ "<insert input id and sequence strings here> Without onlyIfMatches:");
Object[] urls;
try
{
{
System.out.println("too long exception " + ex);
}
- System.out
- .println("<insert input id and sequence strings here> With onlyIfMatches set:");
+ System.out.println(
+ "<insert input id and sequence strings here> With onlyIfMatches set:");
try
{
urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",