Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / util / DBRefUtils.java
index ae0243e..671142b 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.util;
 
+import java.util.Locale;
+
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.HashMap;
@@ -73,7 +75,7 @@ public class DBRefUtils
            // guarantee we always have lowercase entries for canonical string lookups
            for (String k : canonicalSourceNameLookup.keySet())
            {
-             canonicalSourceNameLookup.put(k.toLowerCase(),
+             canonicalSourceNameLookup.put(k.toLowerCase(Locale.ROOT),
                      canonicalSourceNameLookup.get(k));
            }
    }
@@ -98,7 +100,7 @@ public class DBRefUtils
        HashSet<String> srcs = new HashSet<String>();
        for (String src : sources) 
        {
-         srcs.add(src.toUpperCase());
+         srcs.add(src.toUpperCase(Locale.ROOT));
        }
 
        int nrefs = dbrefs.size();
@@ -107,7 +109,7 @@ public class DBRefUtils
        {
          DBRefEntry dbr = dbrefs.get(ib);
          String source = getCanonicalName(dbr.getSource());
-         if (srcs.contains(source.toUpperCase())) 
+         if (srcs.contains(source.toUpperCase(Locale.ROOT))) 
          {
            res.add(dbr);
          }
@@ -181,7 +183,7 @@ public class DBRefUtils
          {
                return null;
          }
-         String canonical = canonicalSourceNameLookup.get(source.toLowerCase());
+         String canonical = canonicalSourceNameLookup.get(source.toLowerCase(Locale.ROOT));
          return canonical == null ? source : canonical;
        }
 
@@ -307,6 +309,15 @@ public class DBRefUtils
 
        };
 
+  private static Regex PARSE_REGEX;
+
+  private static Regex getParseRegex()
+  {
+    return (PARSE_REGEX == null ? PARSE_REGEX = Platform.newRegex(
+            "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)")
+            : PARSE_REGEX);
+  }
+
   /**
    * Parses a DBRefEntry and adds it to the sequence, also a PDBEntry if the
    * database is PDB.
@@ -334,8 +345,7 @@ public class DBRefUtils
          * Check for PFAM style stockhom PDB accession id citation e.g.
          * "1WRI A; 7-80;"
          */
-        Regex r = new com.stevesoft.pat.Regex(
-                "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)");
+        Regex r = getParseRegex();
         if (r.search(acn.trim()))
         {
           String pdbid = r.stringMatched(1);