Merge branch 'JAL-1199-Stk_writing' into rnaml_test
[jalview.git] / src / jalview / io / FileParse.java
index e972679..62237d9 100755 (executable)
@@ -1,13 +1,13 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * 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
  * 
  * 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.
- * 
+ *  
  * 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 
@@ -40,6 +40,21 @@ public class FileParse
   protected char suffixSeparator = '#';
 
   /**
+   * character used to write newlines
+   */
+  protected String newline = System.getProperty("line.separator");
+
+  public void setNewlineString(String nl)
+  {
+    newline = nl;
+  }
+
+  public String getNewlineString()
+  {
+    return newline;
+  }
+
+  /**
    * '#' separated string tagged on to end of filename or url that was clipped
    * off to resolve to valid filename
    */
@@ -374,32 +389,30 @@ public class FileParse
   {
     return dataName;
   }
+
   /**
    * set the (human readable) name or URI for this datasource
+   * 
    * @param dataname
    */
-  protected void setDataName(String dataname) {
+  protected void setDataName(String dataname)
+  {
     dataName = dataname;
   }
-  
 
-  public Reader getReader() throws IOException
+  /**
+   * get the underlying bufferedReader for this data source.
+   * 
+   * @return null if no reader available
+   * @throws IOException
+   */
+  public Reader getReader()
   {
-    if (dataIn != null && dataIn.ready())
+    if (dataIn != null) // Probably don't need to test for readiness &&
+                        // dataIn.ready())
     {
       return dataIn;
     }
     return null;
   }
-
-  public static String checkProtocol(String file)
-  {
-    String protocol = jalview.io.FormatAdapter.FILE;
-  
-    if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
-    {
-      protocol = jalview.io.FormatAdapter.URL;
-    }
-    return protocol;
-  }
 }