JAL-3446 separated out potential exceptions for simplified key mask operation
[jalview.git] / src / jalview / io / ModellerDescription.java
index 7e05b15..48a6903 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
 {
   /**
@@ -88,17 +91,25 @@ public class ModellerDescription
 
     resCode(int v)
     {
-      val = new Integer(v);
+      val = Integer.valueOf(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