JAL-3144 SequenceFetcher without JDatabaseTree
[jalview.git] / src / jalview / ws / SequenceFetcher.java
index 29d4ec7..4526b26 100644 (file)
@@ -33,6 +33,8 @@ import jalview.ws.seqfetcher.ASequenceFetcher;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * This implements the run-time discovery of sequence database clients.
@@ -62,44 +64,30 @@ public class SequenceFetcher extends ASequenceFetcher
   /**
    * return an ordered list of database sources excluding alignment only databases
    */
-  public String[] getOrderedSupportedSources()
+  public String[] getNonAlignmentSources()
   {
     String[] srcs = this.getSupportedDb();
-    ArrayList<String> src = new ArrayList<>();
+    List<String> src = new ArrayList<>();
 
     for (int i = 0; i < srcs.length; i++)
     {
-      boolean skip = false;
+      boolean accept = true;
       for (DbSourceProxy dbs : getSourceProxy(srcs[i]))
       {
         // Skip the alignment databases for the moment - they're not useful for
         // verifying a single sequence against its reference source
         if (dbs.isAlignmentSource())
         {
-          skip = true;
+          accept = false;
+          break;
         }
       }
-      if (skip)
-      {
-        continue;
-      }
+      if (accept)
       {
         src.add(srcs[i]);
       }
     }
-    String[] tosort = src.toArray(new String[0]),
-            sorted = src.toArray(new String[0]);
-    for (int j = 0, jSize = sorted.length; j < jSize; j++)
-    {
-      tosort[j] = tosort[j].toLowerCase();
-    }
-    jalview.util.QuickSort.sort(tosort, sorted);
-    // construct array with all sources listed
-    int i = 0;
-    for (int j = sorted.length - 1; j >= 0; j--, i++)
-    {
-      srcs[i] = sorted[j];
-    }
-    return srcs;
+    Collections.sort(src, String.CASE_INSENSITIVE_ORDER);
+    return src.toArray(new String[src.size()]);
   }
 }