2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
\r
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.ws.seqfetcher;
\r
20 import jalview.datamodel.Alignment;
\r
21 import jalview.datamodel.DBRefSource;
\r
22 import jalview.io.FormatAdapter;
\r
23 import jalview.io.IdentifyFile;
\r
25 import java.util.Hashtable;
\r
28 * common methods for implementations of the DbSourceProxy interface.
\r
33 public abstract class DbSourceProxyImpl implements DbSourceProxy
\r
35 public DbSourceProxyImpl()
\r
37 // default constructor - do nothing probably.
\r
40 private Hashtable props = null;
\r
45 * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
\r
47 public Hashtable getDbSourceProperties()
\r
51 props = new Hashtable();
\r
56 protected void addDbSourceProperty(Object propname)
\r
58 addDbSourceProperty(propname, propname);
\r
61 protected void addDbSourceProperty(Object propname, Object propvalue)
\r
65 props = new Hashtable();
\r
67 props.put(propname, propvalue);
\r
70 boolean queryInProgress = false;
\r
72 protected StringBuffer results = null;
\r
77 * @see jalview.ws.DbSourceProxy#getRawRecords()
\r
79 public StringBuffer getRawRecords()
\r
87 * @see jalview.ws.DbSourceProxy#queryInProgress()
\r
89 public boolean queryInProgress()
\r
91 return queryInProgress;
\r
95 * call to set the queryInProgress flag
\r
98 protected void startQuery()
\r
100 queryInProgress = true;
\r
104 * call to clear the queryInProgress flag
\r
107 protected void stopQuery()
\r
109 queryInProgress = false;
\r
113 * create an alignment from raw text file...
\r
116 * @return null or a valid alignment
\r
117 * @throws Exception
\r
119 protected Alignment parseResult(String result) throws Exception
\r
121 Alignment sequences = null;
\r
122 String format = new IdentifyFile().Identify(result, "Paste");
\r
123 if (FormatAdapter.isValidFormat(format))
\r
125 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
\r
132 public boolean isA(Object dbsourceproperty)
\r
134 assert(dbsourceproperty!=null);
\r
135 return (props==null) ? false : props.containsKey(dbsourceproperty);
\r