2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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/>.
18 package jalview.ws.seqfetcher;
20 import jalview.datamodel.Alignment;
21 import jalview.io.FormatAdapter;
22 import jalview.io.IdentifyFile;
24 import java.util.Hashtable;
27 * common methods for implementations of the DbSourceProxy interface.
32 public abstract class DbSourceProxyImpl implements DbSourceProxy
34 public DbSourceProxyImpl()
36 // default constructor - do nothing probably.
39 private Hashtable props = null;
44 * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
46 public Hashtable getDbSourceProperties()
50 props = new Hashtable();
55 protected void addDbSourceProperty(Object propname)
57 addDbSourceProperty(propname, propname);
60 protected void addDbSourceProperty(Object propname, Object propvalue)
64 props = new Hashtable();
66 props.put(propname, propvalue);
69 boolean queryInProgress = false;
71 protected StringBuffer results = null;
76 * @see jalview.ws.DbSourceProxy#getRawRecords()
78 public StringBuffer getRawRecords()
86 * @see jalview.ws.DbSourceProxy#queryInProgress()
88 public boolean queryInProgress()
90 return queryInProgress;
94 * call to set the queryInProgress flag
97 protected void startQuery()
99 queryInProgress = true;
103 * call to clear the queryInProgress flag
106 protected void stopQuery()
108 queryInProgress = false;
112 * create an alignment from raw text file...
115 * @return null or a valid alignment
118 protected Alignment parseResult(String result) throws Exception
120 Alignment sequences = null;
121 String format = new IdentifyFile().Identify(result, "Paste");
122 if (FormatAdapter.isValidFormat(format))
124 sequences = new FormatAdapter().readFile(result.toString(), "Paste",
131 public boolean isA(Object dbsourceproperty)
133 assert (dbsourceproperty != null);
134 return (props == null) ? false : props.containsKey(dbsourceproperty);