JAL-4152 Remove redundant casts from getInstance usages.
[jalview.git] / src / jalview / io / FileFormats.java
index 19a61cf..d4369bd 100644 (file)
@@ -1,5 +1,27 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.io;
 
+import java.util.Locale;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -7,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
@@ -16,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<String, FileFormatI> formats;
-
-  /*
-   * Formats in this set are capable of being identified by IdentifyFile 
-   */
-  private static Set<FileFormatI> identifiable;
-
   public static FileFormats getInstance()
   {
-    return instance;
+    return ApplicationSingletonProvider.getInstance(FileFormats.class);
   }
 
   /**
@@ -43,6 +56,17 @@ public class FileFormats
     reset();
   }
 
+  /*
+   * A lookup map of file formats by upper-cased name
+   */
+  private Map<String, FileFormatI> formats;
+
+  /*
+   * Formats in this set are capable of being identified by IdentifyFile 
+   */
+  private Set<FileFormatI> 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
@@ -82,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());
@@ -101,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);
   }
 
@@ -154,7 +178,8 @@ 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));
   }
 
   /**