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.
21 package jalview.ws.seqfetcher;
23 import jalview.datamodel.Alignment;
24 import jalview.io.FormatAdapter;
25 import jalview.io.IdentifyFile;
27 import java.util.Hashtable;
30 * common methods for implementations of the DbSourceProxy interface.
35 public abstract class DbSourceProxyImpl implements DbSourceProxy
37 public DbSourceProxyImpl()
39 // default constructor - do nothing probably.
42 private Hashtable props = null;
47 * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
49 public Hashtable getDbSourceProperties()
53 props = new Hashtable();
58 protected void addDbSourceProperty(Object propname)
60 addDbSourceProperty(propname, propname);
63 protected void addDbSourceProperty(Object propname, Object propvalue)
67 props = new Hashtable();
69 props.put(propname, propvalue);
72 boolean queryInProgress = false;
74 protected StringBuffer results = null;
79 * @see jalview.ws.DbSourceProxy#getRawRecords()
81 public StringBuffer getRawRecords()
89 * @see jalview.ws.DbSourceProxy#queryInProgress()
91 public boolean queryInProgress()
93 return queryInProgress;
97 * call to set the queryInProgress flag
100 protected void startQuery()
102 queryInProgress = true;
106 * call to clear the queryInProgress flag
109 protected void stopQuery()
111 queryInProgress = false;
115 * create an alignment from raw text file...
118 * @return null or a valid alignment
121 protected Alignment parseResult(String result) throws Exception
123 Alignment sequences = null;
124 String format = new IdentifyFile().Identify(result, "Paste");
125 if (FormatAdapter.isValidFormat(format))
127 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
134 public boolean isA(Object dbsourceproperty)
136 assert (dbsourceproperty != null);
137 return (props == null) ? false : props.containsKey(dbsourceproperty);