JAL-2344 FileFormats singleton for formats, FileFormatI simplified
[jalview.git] / src / jalview / ws / rest / params / Alignment.java
index 08a242d..a8258e2 100644 (file)
@@ -23,6 +23,7 @@ package jalview.ws.rest.params;
 import jalview.datamodel.AlignmentI;
 import jalview.io.FileFormat;
 import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
 import jalview.io.FormatAdapter;
 import jalview.ws.params.OptionI;
 import jalview.ws.params.simple.BooleanOption;
@@ -147,9 +148,9 @@ public class Alignment extends InputType
 
     if (tok.startsWith("format"))
     {
-      for (FileFormatI fmt : FileFormat.values())
+      for (FileFormatI fmt : FileFormats.getInstance().getFormats())
       {
-        if (fmt.isWritable() && val.equalsIgnoreCase(fmt.toString()))
+        if (fmt.isWritable() && val.equalsIgnoreCase(fmt.getName()))
         {
           format = fmt;
           return true;
@@ -157,12 +158,9 @@ public class Alignment extends InputType
       }
       warnings.append("Invalid alignment format '" + val
               + "'. Must be one of (");
-      for (FileFormatI fmt : FileFormat.values())
+      for (String fmt : FileFormats.getInstance().getWritableFormats(true))
       {
-        if (fmt.isWritable())
-        {
-          warnings.append(" " + fmt).toString();
-        }
+        warnings.append(" ").append(fmt);
       }
       warnings.append(")\n");
     }
@@ -197,28 +195,14 @@ public class Alignment extends InputType
             "Append jalview style /start-end suffix to ID", false, false,
             writeAsFile, null));
 
+    List<String> writable = FileFormats
+            .getInstance().getWritableFormats(true);
     lst.add(new Option("format", "Alignment upload format", true,
-            FileFormat.Fasta.toString(), format.toString(), getWritableFormats(),
+            FileFormat.Fasta.toString(), format.getName(), writable,
             null));
     lst.add(createMolTypeOption("type", "Sequence type", false, type, null));
 
     return lst;
   }
 
-  /**
-   * @return
-   */
-  protected List<String> getWritableFormats()
-  {
-    List<String> formats = new ArrayList<String>();
-    for (FileFormatI ff : FileFormat.values())
-    {
-      if (ff.isWritable())
-      {
-        formats.add(ff.toString());
-      }
-    }
-    return formats;
-  }
-
 }