JAL-1807 Bob's first commit -- Applet loaded; needs image
[jalview.git] / src / jalview / datamodel / CigarBase.java
index cb0bd12..c44cc69 100644 (file)
@@ -1,22 +1,27 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * 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.
+ * 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/>.
+ * 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.datamodel;
 
+import jalview.util.MessageManager;
+
 import java.util.*;
 
 public abstract class CigarBase
@@ -75,7 +80,7 @@ public abstract class CigarBase
   public Object[] getSequenceAndDeletions(String reference, char GapChar)
   {
     int rlength = 0;
-    int[][] deletions = new int[length][];
+    int[][] deletions = javajs.util.AU.newInt2(length);// BH new int[length][];
     int[][] trunc_deletions = null;
     StringBuffer sq = new StringBuffer();
     int cursor = 0, alcursor = 0, start = 0, startpos = 0, end = 0, endpos = 0, delcount = -1;
@@ -141,7 +146,7 @@ public abstract class CigarBase
         endpos = alcursor;
         break;
       default:
-        throw new Error("Unknown SeqCigar operation '" + operation[i] + "'");
+        throw new Error(MessageManager.formatMessage("error.unknown_seq_cigar_operation", new String[]{new StringBuffer(operation[i]).toString()}));
       }
     }
     if (++delcount > 0)
@@ -220,7 +225,7 @@ public abstract class CigarBase
       } while (c >= '0' && c <= '9' && j < l);
       if (j >= l && c >= '0' && c <= '9')
       {
-        throw new Exception("Unterminated cigar string.");
+        throw new Exception(MessageManager.getString("exception.unterminated_cigar_string"));
       }
       try
       {
@@ -229,7 +234,7 @@ public abstract class CigarBase
         i = j;
       } catch (Exception e)
       {
-        throw new Error("Implementation bug in parseCigarString");
+        throw new Error(MessageManager.getString("error.implementation_bug_parse_cigar_string"));
       }
       if (c >= 'a' && c <= 'z')
       {
@@ -241,9 +246,11 @@ public abstract class CigarBase
       }
       else
       {
-        throw new Exception("Unexpected operation '" + c
-                + "' in cigar string (position " + i + " in '"
-                + cigarString + "'");
+        throw new Exception(MessageManager.formatMessage("exception.unexpected_operation_cigar_string_pos", new String[]{
+                       new StringBuffer(c).toString(),
+                       Integer.valueOf(i).toString(),
+                       cigarString
+        }));
       }
     }
     return new Object[]
@@ -266,7 +273,7 @@ public abstract class CigarBase
     }
     if (op != M && op != D && op != I)
     {
-      throw new Error("Implementation error. Invalid operation string.");
+      throw new Error(MessageManager.getString("error.implementation_error_invalid_operation_string"));
     }
     if (range == 0)
     {
@@ -274,8 +281,7 @@ public abstract class CigarBase
     }
     if (range < 0)
     {
-      throw new Error(
-              "Invalid range string (must be zero or positive number)");
+      throw new Error(MessageManager.getString("error.invalid_range_string"));
     }
     int lngth = 0;
     if (operation == null)
@@ -387,8 +393,7 @@ public abstract class CigarBase
     }
     if (start < 0 || start > end)
     {
-      throw new Error(
-              "Implementation Error: deleteRange out of bounds: start must be non-negative and less than end.");
+      throw new Error(MessageManager.getString("error.implementation_error_delete_range_out_of_bounds"));
     }
     // find beginning
     int cursor = 0; // mark the position for the current operation being edited.
@@ -460,10 +465,9 @@ public abstract class CigarBase
           }
           break;
         case D:
-          throw new Error("Implementation error."); // do nothing;
+          throw new Error(MessageManager.getString("error.implementation_error")); // do nothing;
         default:
-          throw new Error("Implementation Error! Unknown operation '"
-                  + oldops[o] + "'");
+          throw new Error(MessageManager.formatMessage("error.implementation_error_unknown_operation", new String[]{new StringBuffer(oldops[o]).toString()}));
         }
         rlength -= remain;
         remain = oldrange[++o]; // number of op characters left to edit