X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAlignFile.java;h=cea28705553b083dd7ab5ea083ec4c3e53d34048;hb=7a1b05d3e521e5d532ad03b23a33ab21675ebd1f;hp=73330754a18bd558f774aa4c502f3ddcc6cd894f;hpb=35ce4609cc8a776b1d85a1f2c2c70aaa106c1a3b;p=jalview.git diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index 7333075..cea2870 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -40,8 +40,8 @@ import java.util.Vector; * @author $author$ * @version $Revision$ */ -public abstract class AlignFile extends FileParse implements - AlignmentFileReaderI, AlignmentFileWriterI +public abstract class AlignFile extends FileParse + implements AlignmentFileReaderI, AlignmentFileWriterI { int noSeqs = 0; @@ -72,7 +72,20 @@ public abstract class AlignFile extends FileParse implements long end; - private boolean parseCalled; + /** + * true if parse() has been called + */ + private boolean parseCalled = false; + + private boolean parseImmediately = true; + + /** + * @return if doParse() was called at construction time + */ + protected boolean isParseImmediately() + { + return parseImmediately; + } /** * Creates a new AlignFile object. @@ -99,7 +112,7 @@ public abstract class AlignFile extends FileParse implements * @param sourceType * What type of file to read from (File, URL, Pasted String) */ - public AlignFile(String dataObject, DataSourceType sourceType) + public AlignFile(Object dataObject, DataSourceType sourceType) throws IOException { this(true, dataObject, sourceType); @@ -117,10 +130,10 @@ public abstract class AlignFile extends FileParse implements * What type of file to read from (File, URL) * @throws IOException */ - public AlignFile(boolean parseImmediately, String dataObject, - DataSourceType sourceType) - throws IOException + public AlignFile(boolean parseImmediately, Object dataObject, + DataSourceType sourceType) throws IOException { + // BH allows File or String super(dataObject, sourceType); initData(); if (parseImmediately) @@ -154,6 +167,11 @@ public abstract class AlignFile extends FileParse implements { super(source); initData(); + + // stash flag in case parse needs to know if it has to autoconfigure or was + // configured after construction + this.parseImmediately = parseImmediately; + if (parseImmediately) { doParse(); @@ -175,11 +193,6 @@ public abstract class AlignFile extends FileParse implements } parseCalled = true; parse(); - // sets the index of each sequence in the alignment - for (int i = 0, c = seqs.size(); i < c; i++) - { - seqs.get(i).setIndex(i); - } } /** @@ -282,9 +295,8 @@ public abstract class AlignFile extends FileParse implements { if (key == null) { - throw new Error( - MessageManager - .getString("error.implementation_error_cannot_have_null_alignment")); + throw new Error(MessageManager.getString( + "error.implementation_error_cannot_have_null_alignment")); } if (value == null) {