+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * \r
+ * This file is part of Jalview.\r
+ * \r
+ * Jalview is free software: you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License \r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
+ * \r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE. See the GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
package jalview.util;\r
\r
import java.util.Vector;\r
* Jalview 2.4 extension allows regular expressions to be used to parse ID\r
* strings and replace the result in the URL. Regex's operate on the whole ID\r
* string given to the matchURL method, if no regex is supplied, then only\r
- * text following the first pipe symbol will be susbstituted.\r
+ * text following the first pipe symbol will be susbstituted. Usage\r
+ * documentation todo.\r
*/\r
private String url_suffix, url_prefix, target, label, regexReplace;\r
\r
label = link.substring(0, sep = link.lastIndexOf("|"));\r
url_prefix = link.substring(sep + 1);\r
regexReplace = null; // implies we trim any prefix if necessary //\r
- // regexReplace=".*\\|?(.*)";\r
+ // regexReplace=".*\\|?(.*)";\r
url_suffix = null;\r
}\r
}\r
}\r
\r
/**\r
+ * Check if URL string was parsed properly.\r
* \r
- * @return true if URL string could not be parsed properly.\r
+ * @return boolean - if false then <code>getInvalidMessage</code> returns an\r
+ * error message\r
*/\r
public boolean isValid()\r
{\r
* return one or more URL strings by applying regex to the given idstring\r
* \r
* @param idstring\r
- * @param onlyIfMatches -\r
- * when true url strings are only made if regex is defined and\r
- * matches\r
+ * @param onlyIfMatches\r
+ * - when true url strings are only made if regex is defined and\r
+ * matches\r
* @return String[] { part of idstring substituted, full substituted url , ..\r
* next part, next url..}\r
*/\r
{ rg.stringMatched(),\r
url_prefix + rg.stringMatched() + url_suffix };\r
} /*\r
- * else if (ns==1) { // take only subgroup match return new String[] {\r
- * rg.stringMatched(1), url_prefix+rg.stringMatched(1)+url_suffix }; }\r
+ * else if (ns==1) { // take only subgroup match return new String[]\r
+ * { rg.stringMatched(1), url_prefix+rg.stringMatched(1)+url_suffix\r
+ * }; }\r
*/\r
else\r
{\r
/*\r
* "AlinkT|Target|http://foo.foo.soo/",\r
* "myUrl1|http://$SEQUENCE_ID=/[0-9]+/=$.someserver.org/foo",\r
- * "myUrl2|http://$SEQUENCE_ID=/(([0-9]+).+([A-Za-z]+))/=$.someserver.org/foo",\r
- * "myUrl3|http://$SEQUENCE_ID=/([0-9]+).+([A-Za-z]+)/=$.someserver.org/foo",\r
- * "myUrl4|target|http://$SEQUENCE_ID$.someserver.org/foo|too",\r
- * "PF1|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/(?:PFAM:)?(.+)/=$",\r
- * "PF2|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/(PFAM:)?(.+)/=$",\r
- * "PF3|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/PFAM:(.+)/=$",\r
- * "NOTFER|http://notfer.org/$SEQUENCE_ID=/(?<!\\s)(.+)/=$",\r
+ * "myUrl2|http://$SEQUENCE_ID=/(([0-9]+).+([A-Za-z]+))/=$.someserver.org/foo"\r
+ * ,\r
+ * "myUrl3|http://$SEQUENCE_ID=/([0-9]+).+([A-Za-z]+)/=$.someserver.org/foo"\r
+ * , "myUrl4|target|http://$SEQUENCE_ID$.someserver.org/foo|too",\r
+ * "PF1|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/(?:PFAM:)?(.+)/=$"\r
+ * ,\r
+ * "PF2|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/(PFAM:)?(.+)/=$"\r
+ * ,\r
+ * "PF3|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/PFAM:(.+)/=$"\r
+ * , "NOTFER|http://notfer.org/$SEQUENCE_ID=/(?<!\\s)(.+)/=$",\r
*/\r
"NESTED|http://nested/$SEQUENCE_ID=/^(?:Label:)?(?:(?:gi\\|(\\d+))|([^:]+))/=$/nested" };\r
String[] idstrings = new String[]\r
* //"123123312", "123123 ABCDE foo", "PFAM:PF23943",\r
*/\r
"Label:gi|9234|pdb|102L|A" };\r
-\r
+ // TODO: test the setLabel method.\r
for (int i = 0; i < links.length; i++)\r
{\r
UrlLink ul = new UrlLink(links[i]);\r
// TODO Auto-generated method stub\r
return dynamic;\r
}\r
+\r
+ public void setLabel(String newlabel)\r
+ {\r
+ this.label = newlabel;\r
+ }\r
}\r