2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.seqfetcher;
21 import jalview.datamodel.Alignment;
22 import jalview.io.FormatAdapter;
23 import jalview.io.IdentifyFile;
25 import java.util.Hashtable;
28 * common methods for implementations of the DbSourceProxy interface.
33 public abstract class DbSourceProxyImpl implements DbSourceProxy
35 public DbSourceProxyImpl()
37 // default constructor - do nothing probably.
40 private Hashtable props = null;
45 * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
47 public Hashtable getDbSourceProperties()
51 props = new Hashtable();
56 protected void addDbSourceProperty(Object propname)
58 addDbSourceProperty(propname, propname);
61 protected void addDbSourceProperty(Object propname, Object propvalue)
65 props = new Hashtable();
67 props.put(propname, propvalue);
70 boolean queryInProgress = false;
72 protected StringBuffer results = null;
77 * @see jalview.ws.DbSourceProxy#getRawRecords()
79 public StringBuffer getRawRecords()
87 * @see jalview.ws.DbSourceProxy#queryInProgress()
89 public boolean queryInProgress()
91 return queryInProgress;
95 * call to set the queryInProgress flag
98 protected void startQuery()
100 queryInProgress = true;
104 * call to clear the queryInProgress flag
107 protected void stopQuery()
109 queryInProgress = false;
113 * create an alignment from raw text file...
116 * @return null or a valid alignment
119 protected Alignment parseResult(String result) throws Exception
121 Alignment sequences = null;
122 String format = new IdentifyFile().Identify(result, "Paste");
123 if (FormatAdapter.isValidFormat(format))
125 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
132 public boolean isA(Object dbsourceproperty)
134 assert (dbsourceproperty != null);
135 return (props == null) ? false : props.containsKey(dbsourceproperty);