JAL-2316 Refactoring of functionality to provide urls to gui
[jalview.git] / src / jalview / util / UrlProviderI.java
index 2118f7e..a0289e5 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.util;
 
-import java.util.HashMap;
 import java.util.Vector;
 
 /**
@@ -31,57 +30,77 @@ import java.util.Vector;
  */
 public interface UrlProviderI
 {
-  /**
-   * Get all the URL links
-   * 
-   * @return all URL links
+
+  /*
+   * Default sequence URL link label for EMBL-EBI search
    */
-  public HashMap<String, UrlLink> getUrlLinks();
+  public static final String DEFAULT_LABEL = "EMBL-EBI Search";
+
+  /*
+   * Default sequence URL link string for EMBL-EBI search
+   */
+  public static final String DEFAULT_STRING = DEFAULT_LABEL
+          + "|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$";
 
   /**
    * Get names and urls in as strings for display
    * 
-   * @param nameLinks
-   * @param urlLinks
    */
-  public void getLinksForDisplay(Vector<String> nameLinks,
-          Vector<String> urlLinks);
+  Vector<String> getLinksForDisplay();
 
   /**
-   * Get the default URL
+   * Get the id of the default URL
    * 
    * @return id of the default URL
    */
-  public String getDefaultUrl();
+  String getDefaultUrl();
+
+  /**
+   * Get the link for the default URL
+   * 
+   * @seqid sequence id for which to build link
+   * @return link for the default URL
+   */
+  String getDefaultUrl(String seqid);
+
+  /**
+   * Get the target of thelink for the default URL
+   * 
+   * @seqid sequence id for which to build link
+   * @return target of link for the default URL
+   */
+  String getDefaultTarget(String seqid);
 
   /**
    * Set the default URL
    * 
    * @param id
    *          the id of the URL to set as default
+   * @return true if setting was successful, false otherwise
    */
-  public void setDefaultUrl(String id);
+  boolean setDefaultUrl(String id);
 
   /**
    * Write out all URLs as a string suitable for serialising
    * 
    * @return string representation of available URLs
    */
-  public String writeUrlsAsString();
+  String writeUrlsAsString();
 
   /**
-   * Set URL links from string
+   * Set URL links from pair of collections
    * 
-   * @param cachedUrl
-   *          string representation of URL links, i.e. | separated
+   * @param names
+   * @param urls
    */
-  public void setUrlLinks(String cachedUrl);
+  void setUrlLinks(Vector<String> names, Vector<String> urls)
+          throws IllegalArgumentException;
 
   /**
-   * Set URL links from collection
+   * Choose the default URL in the event of the selected default being
+   * unavailable
    * 
-   * @param links
-   *          hashmap containing string indexed UrlLinks
+   * @return id of chosen default url
    */
-  public void setUrlLinks(HashMap<String, UrlLink> links);
+  String chooseDefaultUrl();
 }