JAL-1551 formatting
[jalview.git] / src / jalview / io / FileParse.java
index d20b468..764715f 100755 (executable)
  */
 package jalview.io;
 
-import java.io.*;
-import java.net.*;
+import jalview.util.MessageManager;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.zip.GZIPInputStream;
 
 /**
@@ -50,7 +61,7 @@ public class FileParse
 
   public void setNewlineString(String nl)
   {
-    newline = nl;
+      newline = nl;
   }
 
   public String getNewlineString()
@@ -94,11 +105,12 @@ public class FileParse
   {
     if (from == null)
     {
-      throw new Error(
-              "Implementation error. Null FileParse in copy constructor");
+      throw new Error(MessageManager.getString("error.implementation_error_null_fileparse"));
     }
     if (from == this)
+    {
       return;
+    }
     index = ++from.index;
     inFile = from.inFile;
     suffixSeparator = from.suffixSeparator;
@@ -156,7 +168,7 @@ public class FileParse
         {
           warningMessage = "Failed  to resolve as a GZ stream ("
                   + x.getMessage() + ")";
-          x.printStackTrace();
+          // x.printStackTrace();
         }
         ;
       }
@@ -208,7 +220,7 @@ public class FileParse
     {
       if (e != null)
       {
-        throw new IOException("Failed to resolve GZIP stream", e);
+        throw new IOException(MessageManager.getString("exception.failed_to_resolve_gzip_stream"), e);
       }
       throw q;
     }
@@ -263,14 +275,12 @@ public class FileParse
         {
           if (checkFileSource(suffixLess))
           {
-            throw new IOException("Problem opening " + inFile
-                    + " (also tried " + suffixLess + ") : " + errormessage);
+            throw new IOException(MessageManager.formatMessage("exception.problem_opening_file_also_tried", new String[]{inFile.getName(),suffixLess,errormessage}));
           }
         }
         else
         {
-          throw new IOException("Problem opening " + inFile + " : "
-                  + errormessage);
+          throw new IOException(MessageManager.formatMessage("exception.problem_opening_file", new String[]{inFile.getName(),errormessage}));
         }
       }
     }
@@ -282,7 +292,9 @@ public class FileParse
         {
           checkURLSource(fileStr);
           if (suffixSeparator == '#')
+           {
             extractSuffix(fileStr); // URL lref is stored for later reference.
+          }
         } catch (IOException e)
         {
           String suffixLess = extractSuffix(fileStr);
@@ -324,7 +336,9 @@ public class FileParse
       {
         String suffixLess = extractSuffix(fileStr);
         if (suffixLess != null)
+        {
           is = getClass().getResourceAsStream("/" + suffixLess);
+        }
       }
       if (is != null)
       {
@@ -345,8 +359,7 @@ public class FileParse
     if (dataIn == null || error)
     {
       // pass up the reason why we have no source to read from
-      throw new IOException("Failed to read data from source:\n"
-              + errormessage);
+      throw new IOException(MessageManager.formatMessage("exception.failed_to_read_data_from_source", new String[]{errormessage}));
     }
     error = false;
     dataIn.mark(READAHEAD_LIMIT);
@@ -366,15 +379,17 @@ public class FileParse
     }
     else
     {
-      throw new IOException("Unitialised Source Stream");
+      throw new IOException(MessageManager.getString("exception.no_init_source_stream"));
     }
   }
 
   public String nextLine() throws IOException
   {
     if (!error)
+    {
       return dataIn.readLine();
-    throw new IOException("Invalid Source Stream:" + errormessage);
+    }
+    throw new IOException(MessageManager.formatMessage("exception.invalid_source_stream", new String[]{errormessage}));
   }
 
   public boolean isValid()
@@ -406,8 +421,7 @@ public class FileParse
     }
     else
     {
-      throw new IOException(
-              "Implementation Error: Reset called for invalid source.");
+      throw new IOException(MessageManager.getString("error.implementation_error_reset_called_for_invalid_source"));
     }
   }