JAL-1926 JAL-2106 use enum for ‘DEFAULT_STRUCTURE_FORMAT’ property values
authorJim Procter <jprocter@issues.jalview.org>
Wed, 20 Jul 2016 15:18:01 +0000 (16:18 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 20 Jul 2016 15:21:27 +0000 (16:21 +0100)
src/jalview/structure/StructureImportSettings.java
src/jalview/ws/dbsources/Pdb.java

index b23fd53..8a321ce 100644 (file)
@@ -27,6 +27,12 @@ public class StructureImportSettings
   private static boolean processHETATMs = false;
 
   private static String currentDefaultFormat = DBRefSource.PDB;
+  public enum StructureFormat
+  {
+    PDB, MMCIF
+  };
+
+  private static StructureFormat currentDefaultFormat = StructureFormat.PDB;
 
   public static void addSettings(boolean addAlignmentAnnotations,
           boolean predictSecStr, boolean externalSecStr)
@@ -82,12 +88,13 @@ public class StructureImportSettings
 
   public static String getCurrentDefaultFormat()
   {
-    return currentDefaultFormat;
+    return currentDefaultFormat.toString();
   }
 
   public static void setCurrentDefaultFormat(String currentDefaultFormat)
   {
-    StructureImportSettings.currentDefaultFormat = currentDefaultFormat;
+    StructureImportSettings.currentDefaultFormat = StructureFormat
+            .valueOf(currentDefaultFormat);
   }
 
   public static boolean isProcessHETATMs()
index d945699..a06f0c8 100644 (file)
@@ -31,6 +31,7 @@ import jalview.datamodel.SequenceI;
 import jalview.io.FormatAdapter;
 import jalview.io.PDBFeatureSettings;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureFormat;
 import jalview.util.MessageManager;
 import jalview.ws.ebi.EBIFetchClient;
 
@@ -132,9 +133,8 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String ext = StructureImportSettings.getCurrentDefaultFormat()
-            .equalsIgnoreCase("mmcif") ? ".cif"
-            : ".xml";
+    String ext = StructureImportSettings.getCurrentDefaultFormat().equals(
+            StructureFormat.MMCIF) ? ".cif" : ".xml";
     EBIFetchClient ebi = new EBIFetchClient();
     file = ebi.fetchDataAsFile("pdb:" + id,
             StructureImportSettings.getCurrentDefaultFormat().toLowerCase(),