private boolean parseImmediately = true;
+ private boolean dataClosed = false;
+
/**
* @return if doParse() was called at construction time
*/
public AlignFile(boolean parseImmediately, FileParse source)
throws IOException
{
+ this(parseImmediately, source, true);
+ }
+
+ public AlignFile(boolean parseImmediately, FileParse source,
+ boolean closeData) throws IOException
+ {
super(source);
initData();
if (parseImmediately)
{
- doParse();
+ doParse(closeData);
}
}
*/
public void doParse() throws IOException
{
+ doParse(true);
+ }
+
+ public void doParse(boolean closeData) throws IOException
+ {
if (parseCalled)
{
throw new IOException(
}
parseCalled = true;
parse();
- dataIn.close();
+ if (closeData && !dataClosed)
+ {
+ dataIn.close();
+ dataClosed = true;
+ }
}
/**
*/
package jalview.io;
+import java.io.IOException;
+
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
-import java.io.IOException;
-
/**
* DOCUMENT ME!
*
public FastaFile(FileParse source) throws IOException
{
- super(source);
+ this(source, true);
+ }
+
+ public FastaFile(FileParse source, boolean closeData) throws IOException
+ {
+ super(true, source, closeData);
}
public FastaFile(SequenceI[] seqs)
} catch (IOException q)
{
}
- FastaFile parser = new FastaFile(this);
+ // Opening a FastaFile object with the remainder of this object's dataIn.
+ // Tell the constructor to NOT close the dataIn when finished.
+ FastaFile parser = new FastaFile(this, false);
List<SequenceI> includedseqs = parser.getSeqs();
SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs);
return false;
}
input.mark(4);
-
+
// get first 2 bytes or return false
byte[] bytes = new byte[2];
int read = input.read(bytes);
{
return false;
}
-
+
int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
return (GZIPInputStream.GZIP_MAGIC == header);
}