/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
* \r
- * This program 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 2\r
- * of the License, or (at your option) any later version.\r
+ * This file is part of Jalview.\r
* \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\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
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\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.ws.seqfetcher;\r
\r
* Retrieve an instance of the proxy for the given source\r
* \r
* @param db\r
- * database source string TODO: add version string/wildcard for\r
- * retrieval of specific DB source/version combinations.\r
+ * database source string TODO: add version string/wildcard for\r
+ * retrieval of specific DB source/version combinations.\r
* @return an instance of DbSourceProxy for that db.\r
*/\r
public DbSourceProxy getSourceProxy(String db)\r
* dbrefsource\r
* \r
* @param dbSourceProxy\r
- * reference for class implementing\r
- * jalview.ws.seqfetcher.DbSourceProxy\r
+ * reference for class implementing\r
+ * jalview.ws.seqfetcher.DbSourceProxy\r
* @throws java.lang.IllegalArgumentException\r
- * if class does not implement\r
- * jalview.ws.seqfetcher.DbSourceProxy\r
+ * if class does not implement jalview.ws.seqfetcher.DbSourceProxy\r
*/\r
protected void addDBRefSourceImpl(Class dbSourceProxy)\r
throws java.lang.IllegalArgumentException\r
return false;\r
}\r
\r
+ /**\r
+ * select sources which are implemented by instances of the given class\r
+ * \r
+ * @param class that implements DbSourceProxy\r
+ * @return null or vector of source names for fetchers\r
+ */\r
+ public String[] getDbInstances(Class class1)\r
+ {\r
+ if (!jalview.ws.seqfetcher.DbSourceProxy.class.isAssignableFrom(class1))\r
+ {\r
+ throw new Error(\r
+ "Implmentation Error - getDbInstances must be given a class that implements jalview.ws.seqfetcher.DbSourceProxy (was given '"\r
+ + class1 + "')");\r
+ }\r
+ if (FETCHABLEDBS == null)\r
+ {\r
+ return null;\r
+ }\r
+ String[] sources = null;\r
+ Vector src = new Vector();\r
+ Enumeration dbs = FETCHABLEDBS.keys();\r
+ while (dbs.hasMoreElements())\r
+ {\r
+ String dbn = (String) dbs.nextElement();\r
+ DbSourceProxy dbp = (DbSourceProxy) FETCHABLEDBS.get(dbn);\r
+ if (class1.isAssignableFrom(dbp.getClass()))\r
+ {\r
+ src.addElement(dbn);\r
+ }\r
+ }\r
+ if (src.size() > 0)\r
+ {\r
+ src.copyInto(sources = new String[src.size()]);\r
+ }\r
+ return sources;\r
+ }\r
}\r