JAL-3253 temporary branch SwingJS upgrade with testNG fixes Java 8
[jalview.git] / src / jalview / io / ModellerDescription.java
index 7e05b15..20bf736 100755 (executable)
@@ -22,9 +22,12 @@ package jalview.io;
 
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.SequenceI;
+import jalview.util.Platform;
 
 import java.util.List;
 
+import com.stevesoft.pat.Regex;
+
 public class ModellerDescription
 {
   /**
@@ -91,14 +94,22 @@ public class ModellerDescription
       val = new Integer(v);
       field = val.toString();
     }
-  };
+  }
+
+  private static Regex VALIDATION_REGEX;
+
+  private static Regex getRegex()
+  {
+    return (VALIDATION_REGEX == null
+            ? VALIDATION_REGEX = Platform
+                    .newRegex("\\s*((([-0-9]+).?)|FIRST|LAST|@)", null)
+            : VALIDATION_REGEX);
+  }
 
   private resCode validResidueCode(String field)
   {
     Integer val = null;
-    com.stevesoft.pat.Regex r = new com.stevesoft.pat.Regex(
-            "\\s*((([-0-9]+).?)|FIRST|LAST|@)");
-
+    Regex r = getRegex();
     if (!r.search(field))
     {
       return null; // invalid
@@ -168,7 +179,6 @@ public class ModellerDescription
                   // field '" + field + "'");
                   type = -1; /* invalid field! - throw the FieldSet away */
                 }
-                ;
               }
               fields.put(Fields[i++], field);
               if (st.hasMoreTokens())