org.biojava.bio.seq.io
Interface SymbolReader


public interface SymbolReader

Encapsulate a stream of Symbols being parsed from some input stream. This allows SymbolList creation to be fully decoupled from stream parsing.

Since:
1.1 [newio proposal]
Author:
Thomas Down

Method Summary
 Alphabet getAlphabet()
          Find the alphabet of all symbols which may be returned by this SymbolReader.
 boolean hasMoreSymbols()
          Determine if there are more symbols left to read in this stream.
 Symbol readSymbol()
          Return a single symbol from the stream.
 int readSymbols(Symbol[] buffer, int start, int length)
          Read one or more symbols from the stream.
 

Method Detail

getAlphabet

public Alphabet getAlphabet()
Find the alphabet of all symbols which may be returned by this SymbolReader. NOTE: SymbolList implementations are expected to perform any necessary validation of returned Symbols. Client code should not need to perform any extra validation.


readSymbol

public Symbol readSymbol()
                  throws java.io.IOException,
                         IllegalSymbolException
Return a single symbol from the stream.

Throws:
java.io.IOException - if an error occured on the stream, or the end of the stream has already been reached.
IllegalSymbolException - if a parse error occured.

readSymbols

public int readSymbols(Symbol[] buffer,
                       int start,
                       int length)
                throws java.io.IOException,
                       IllegalSymbolException
Read one or more symbols from the stream.

Parameters:
buffer - the destination for read symbols.
start - a start offset within the buffer.
length - the maximum number of Symbols to read.
Returns:
the number of Symbols which were actually read.
Throws:
java.io.IOException - if an error occured on the stream, or the end of the stream has already been reached.
IllegalSymbolException - if a parse error occured.

hasMoreSymbols

public boolean hasMoreSymbols()
Determine if there are more symbols left to read in this stream.