X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FFileFormats.java;h=baf2504403b3f8bad8131105fca82b5c0dd61514;hb=304e64fb34b32659be1bbfd39fb4e15b2f79586e;hp=aadcdb9d23bb3c7da23f91aa78506e18c29c414c;hpb=f4766a7bbcfae845fc95923b01fa14ff83d589ff;p=jalview.git diff --git a/src/jalview/io/FileFormats.java b/src/jalview/io/FileFormats.java index aadcdb9..baf2504 100644 --- a/src/jalview/io/FileFormats.java +++ b/src/jalview/io/FileFormats.java @@ -20,6 +20,8 @@ */ package jalview.io; +import java.util.Locale; + import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap; @@ -27,6 +29,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import jalview.bin.ApplicationSingletonProvider; +import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; + /** * A singleton registry of alignment file formats known to Jalview. On startup, * the 'built-in' formats are added (from the FileFormat enum). Additional @@ -36,23 +41,11 @@ import java.util.Set; * @author gmcarstairs * */ -public class FileFormats +public class FileFormats implements ApplicationSingletonI { - private static FileFormats instance = new FileFormats(); - - /* - * A lookup map of file formats by upper-cased name - */ - private static Map formats; - - /* - * Formats in this set are capable of being identified by IdentifyFile - */ - private static Set identifiable; - public static FileFormats getInstance() { - return instance; + return (FileFormats) ApplicationSingletonProvider.getInstance(FileFormats.class); } /** @@ -63,6 +56,17 @@ public class FileFormats reset(); } + /* + * A lookup map of file formats by upper-cased name + */ + private Map formats; + + /* + * Formats in this set are capable of being identified by IdentifyFile + */ + private Set identifiable; + + /** * Reset to just the built-in file formats packaged with Jalview. These are * added (and will be shown in menus) in the order of their declaration in the @@ -102,7 +106,7 @@ public class FileFormats protected void registerFileFormat(FileFormatI format, boolean isIdentifiable) { - String name = format.getName().toUpperCase(); + String name = format.getName().toUpperCase(Locale.ROOT); if (formats.containsKey(name)) { System.err.println("Overwriting file format: " + format.getName()); @@ -121,7 +125,7 @@ public class FileFormats */ public void deregisterFileFormat(String name) { - FileFormatI ff = formats.remove(name.toUpperCase()); + FileFormatI ff = formats.remove(name.toUpperCase(Locale.ROOT)); identifiable.remove(ff); } @@ -174,7 +178,7 @@ public class FileFormats */ public FileFormatI forName(String format) { - return format == null ? null : formats.get(format.toUpperCase()); + return format == null ? null : formats.get(format.toUpperCase(Locale.ROOT)); } /**