JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / util / DBRefUtils.java
index 197261a..fb54bba 100755 (executable)
@@ -32,6 +32,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import com.stevesoft.pat.Regex;
 
@@ -95,14 +96,14 @@ public class DBRefUtils
        }
 
        // BH TODO (what?)
-       HashSet<String> srcs = new HashSet<>();
+       HashSet<String> srcs = new HashSet<String>();
        for (String src : sources) 
        {
          srcs.add(src.toUpperCase());
        }
 
        int nrefs = dbrefs.size();
-       List<DBRefEntry> res = new ArrayList<>();
+       List<DBRefEntry> res = new ArrayList<DBRefEntry>();
        for (int ib = 0; ib < nrefs; ib++) 
        {
          DBRefEntry dbr = dbrefs.get(ib);
@@ -216,7 +217,7 @@ public class DBRefUtils
         * @return
         */
        public static List<DBRefEntry> searchRefs(List<DBRefEntry> refs, String accId) {
-               List<DBRefEntry> rfs = new ArrayList<>();
+               List<DBRefEntry> rfs = new ArrayList<DBRefEntry>();
                if (refs == null || accId == null) {
                        return rfs;
                }
@@ -242,7 +243,7 @@ public class DBRefUtils
         * @return
         */
        static List<DBRefEntry> searchRefs(List<DBRefEntry> refs, DBRefEntry entry, DbRefComp comparator, int mode) {
-               List<DBRefEntry> rfs = new ArrayList<>();
+               List<DBRefEntry> rfs = new ArrayList<DBRefEntry>();
                if (refs == null || entry == null) {
                        return rfs;
                }
@@ -449,14 +450,6 @@ public class DBRefUtils
     return matches;
   }
 
-  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]+)", null)
-            : PARSE_REGEX);
-  }
        /**
         * Parses a DBRefEntry and adds it to the sequence, also a PDBEntry if the
         * database is PDB.
@@ -478,7 +471,7 @@ public class DBRefUtils
                                /*
                                 * Check for PFAM style stockhom PDB accession id citation e.g. "1WRI A; 7-80;"
                                 */
-        Regex r = getParseRegex();
+                               Regex r = new com.stevesoft.pat.Regex("([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)");
                                if (r.search(acn.trim())) {
                                        String pdbid = r.stringMatched(1);
                                        String chaincode = r.stringMatched(2);
@@ -565,7 +558,7 @@ public class DBRefUtils
         * @return
         */
        public static List<DBRefEntry> searchRefsForSource(List<DBRefEntry> dbRefs, String source) {
-               List<DBRefEntry> matches = new ArrayList<>();
+               List<DBRefEntry> matches = new ArrayList<DBRefEntry>();
                if (dbRefs != null && source != null) {
                        for (DBRefEntry dbref : dbRefs) {
                                if (source.equalsIgnoreCase(dbref.getSource())) {
@@ -628,9 +621,7 @@ public class DBRefUtils
                bsSelect.set(0, dbrefs.size());
 
                if (!selectRefsBS(dbrefs, isProtein ? DBRefSource.PROTEIN_MASK : DBRefSource.DNA_CODING_MASK, bsSelect))
-    {
-      return;
-    }
+                       return;
 
 //      selfs.addAll(selfArray);
 //    }
@@ -640,9 +631,7 @@ public class DBRefUtils
                        DBRefEntry p = pr.get(ip);
                        for (int i = bsSelect.nextSetBit(0); i >= 0; i = bsSelect.nextSetBit(i + 1)) {
                                if (dbrefs.get(i) == p)
-        {
-          bsSelect.clear(i);
-        }
+                                       bsSelect.clear(i);
                        }
 //      while (selfs.contains(p))
 //      {
@@ -666,9 +655,7 @@ public class DBRefUtils
                                // TODO: promote transcript refs ??
                        }
                        if (keys == 0 || !selectRefsBS(dbrefs, keys, bsSelect))
-      {
-        return;
-      }
+                               return;
 //      if (candidates != null)
                        {
                                for (int ic = bsSelect.nextSetBit(0); ic >= 0; ic = bsSelect.nextSetBit(ic + 1))