JAL-1997 database browser support tooltip if available
[jalview.git] / src / jalview / ws / seqfetcher / DbSourceProxyImpl.java
index 85a729d..0a4d9a8 100644 (file)
@@ -24,7 +24,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
 
-import java.util.Hashtable;
+import com.stevesoft.pat.Regex;
 
 /**
  * common methods for implementations of the DbSourceProxy interface.
@@ -34,50 +34,21 @@ import java.util.Hashtable;
  */
 public abstract class DbSourceProxyImpl implements DbSourceProxy
 {
-  public DbSourceProxyImpl()
-  {
-    // default constructor - do nothing probably.
-  }
-
-  private Hashtable props = null;
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
-   */
-  public Hashtable getDbSourceProperties()
-  {
-    if (props == null)
-    {
-      props = new Hashtable();
-    }
-    return props;
-  }
+  boolean queryInProgress = false;
 
-  protected void addDbSourceProperty(Object propname)
-  {
-    addDbSourceProperty(propname, propname);
-  }
+  protected StringBuffer results = null;
 
-  protected void addDbSourceProperty(Object propname, Object propvalue)
+  public DbSourceProxyImpl()
   {
-    if (props == null)
-    {
-      props = new Hashtable();
-    }
-    props.put(propname, propvalue);
   }
 
-  boolean queryInProgress = false;
-
-  protected StringBuffer results = null;
-
   /*
    * (non-Javadoc)
    * 
    * @see jalview.ws.DbSourceProxy#getRawRecords()
    */
+  @Override
   public StringBuffer getRawRecords()
   {
     return results;
@@ -88,6 +59,7 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy
    * 
    * @see jalview.ws.DbSourceProxy#queryInProgress()
    */
+  @Override
   public boolean queryInProgress()
   {
     return queryInProgress;
@@ -131,10 +103,54 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy
   }
 
   @Override
-  public boolean isA(Object dbsourceproperty)
+  public String getAccessionIdFromQuery(String query)
+  {
+    Regex vgr = getAccessionValidator();
+    if (vgr == null)
+    {
+      return query;
+    }
+    vgr.search(query);
+    if (vgr.numSubs() > 0)
+    {
+      return (vgr.stringMatched(1));
+    }
+    else
+    {
+      return (vgr.stringMatched());
+    }
+  }
+
+  /**
+   * Default is only one accession id per query - override if more are allowed.
+   */
+  @Override
+  public int getMaximumQueryCount()
+  {
+    return 1;
+  }
+
+  /**
+   * Returns false - override to return true for DNA coding data sources
+   */
+  @Override
+  public boolean isDnaCoding()
   {
-    assert (dbsourceproperty != null);
-    return (props == null) ? false : props.containsKey(dbsourceproperty);
+    return false;
   }
 
+  /**
+   * Answers false - override as required in subclasses
+   */
+  @Override
+  public boolean isAlignmentSource()
+  {
+    return false;
+  }
+
+  @Override
+  public String getDescription()
+  {
+    return null;
+  }
 }