From: Jim Procter Date: Wed, 20 Jul 2016 15:18:01 +0000 (+0100) Subject: JAL-1926 JAL-2106 use enum for ‘DEFAULT_STRUCTURE_FORMAT’ property values X-Git-Tag: Release_2_10_0~135^2^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=63c563ea81cef0fc7743a08a45d6b43a9818d033;p=jalview.git JAL-1926 JAL-2106 use enum for ‘DEFAULT_STRUCTURE_FORMAT’ property values --- diff --git a/src/jalview/structure/StructureImportSettings.java b/src/jalview/structure/StructureImportSettings.java index b23fd53..8a321ce 100644 --- a/src/jalview/structure/StructureImportSettings.java +++ b/src/jalview/structure/StructureImportSettings.java @@ -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() diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index d945699..a06f0c8 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -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(),