X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAlignFile.java;h=48f65cf9f5e241922aabf9715e65e5398806c033;hb=refs%2Fheads%2Ffeatures%2FJAL-722alignmentProperties;hp=3202ac9f8b067fddcbf26f82e52811390f9fcdf9;hpb=4d71acba1cc4999e8e4061ec3e9ae55e1b37084e;p=jalview.git diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index 3202ac9..48f65cf 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -22,9 +22,10 @@ package jalview.io; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Hashtable; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Vector; import jalview.datamodel.AlignmentAnnotation; @@ -66,7 +67,7 @@ public abstract class AlignFile extends FileParse /** * Properties to be added to generated alignment object */ - private Hashtable properties; + private Map properties; long start; @@ -288,13 +289,11 @@ public abstract class AlignFile extends FileParse */ public void addProperties(AlignmentI al) { - if (properties != null && properties.size() > 0) + if (properties != null) { - Enumeration keys = properties.keys(); - Enumeration vals = properties.elements(); - while (keys.hasMoreElements()) + for (Entry prop : properties.entrySet()) { - al.setProperty(keys.nextElement(), vals.nextElement()); + al.setProperty(prop.getKey(), prop.getValue()); } } } @@ -309,12 +308,12 @@ public abstract class AlignFile extends FileParse * @param value * - non-null value */ - protected void setAlignmentProperty(Object key, Object value) + protected void setAlignmentProperty(String key, String value) { if (key == null) { - throw new Error(MessageManager.getString( - "error.implementation_error_cannot_have_null_alignment")); + throw new Error( + "Implementation error: Cannot have null alignment property key."); } if (value == null) { @@ -322,12 +321,12 @@ public abstract class AlignFile extends FileParse } if (properties == null) { - properties = new Hashtable(); + properties = new Hashtable<>(); } properties.put(key, value); } - protected Object getAlignmentProperty(Object key) + protected String getAlignmentProperty(String key) { if (properties != null && key != null) { @@ -341,9 +340,9 @@ public abstract class AlignFile extends FileParse */ protected void initData() { - seqs = new Vector(); - annotations = new Vector(); - seqGroups = new ArrayList(); + seqs = new Vector<>(); + annotations = new Vector<>(); + seqGroups = new ArrayList<>(); parseCalled = false; } @@ -356,7 +355,7 @@ public abstract class AlignFile extends FileParse @Override public void setSeqs(SequenceI[] s) { - seqs = new Vector(); + seqs = new Vector<>(); for (int i = 0; i < s.length; i++) { @@ -427,7 +426,7 @@ public abstract class AlignFile extends FileParse { if (newickStrings == null) { - newickStrings = new Vector(); + newickStrings = new Vector<>(); } newickStrings.addElement(new String[] { treeName, newickString }); }