JAL-1499 patch from Mungo Carstairs
[jalview.git] / src / jalview / io / AlignFile.java
old mode 100755 (executable)
new mode 100644 (file)
index 7550a5b..977cb25
@@ -1,19 +1,21 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
  * Copyright (C) 2014 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.io;
@@ -26,6 +28,8 @@ import jalview.datamodel.SequenceI;
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
 import java.util.Vector;
 
 /**
@@ -53,7 +57,7 @@ public abstract class AlignFile extends FileParse
   /**
    * Properties to be added to generated alignment object
    */
-  protected Hashtable properties;
+  protected Hashtable<Object, Object> properties;
 
   long start;
 
@@ -66,6 +70,10 @@ public abstract class AlignFile extends FileParse
    */
   public AlignFile()
   {
+    // Shouldn't we init data structures (JBPNote: not sure - initData is for
+    // initialising the structures used for reading from a datasource, and the
+    // bare constructor hasn't got any datasource)
+    initData();
   }
 
   /**
@@ -124,7 +132,7 @@ public abstract class AlignFile extends FileParse
 
     for (int i = 0; i < seqs.size(); i++)
     {
-      s[i] = (SequenceI) seqs.elementAt(i);
+      s[i] = seqs.elementAt(i);
     }
 
     return s;
@@ -167,8 +175,8 @@ public abstract class AlignFile extends FileParse
   {
     if (properties != null && properties.size() > 0)
     {
-      Enumeration keys = properties.keys();
-      Enumeration vals = properties.elements();
+      Enumeration<Object> keys = properties.keys();
+      Enumeration<Object> vals = properties.elements();
       while (keys.hasMoreElements())
       {
         al.setProperty(keys.nextElement(), vals.nextElement());
@@ -199,7 +207,7 @@ public abstract class AlignFile extends FileParse
     }
     if (properties == null)
     {
-      properties = new Hashtable();
+      properties = new Hashtable<Object, Object>();
     }
     properties.put(key, value);
   }
@@ -218,11 +226,20 @@ public abstract class AlignFile extends FileParse
    */
   protected void initData()
   {
-    seqs = new Vector();
+    seqs = new Vector<SequenceI>();
     annotations = new Vector();
   }
 
   /**
+   * Return the alignment properties (or null if none set)
+   * 
+   * @return
+   */
+  protected Set<Map.Entry<Object, Object>> getAlignmentProperties()
+  {
+    return (this.properties == null ? null : this.properties.entrySet());
+  }
+  /**
    * DOCUMENT ME!
    * 
    * @param s
@@ -230,7 +247,7 @@ public abstract class AlignFile extends FileParse
    */
   protected void setSeqs(SequenceI[] s)
   {
-    seqs = new Vector();
+    seqs = new Vector<SequenceI>();
 
     for (int i = 0; i < s.length; i++)
     {
@@ -290,13 +307,13 @@ public abstract class AlignFile extends FileParse
   /**
    * vector of String[] treeName, newickString pairs
    */
-  Vector newickStrings = null;
+  Vector<String[]> newickStrings = null;
 
   protected void addNewickTree(String treeName, String newickString)
   {
     if (newickStrings == null)
     {
-      newickStrings = new Vector();
+      newickStrings = new Vector<String[]>();
     }
     newickStrings.addElement(new String[]
     { treeName, newickString });