de.unibi.techfak.jpredictor.sequences
Class SequenceEnumerator

java.lang.Object
  extended by de.unibi.techfak.jpredictor.sequences.SequenceEnumerator
All Implemented Interfaces:
SequenceEnumeration

public class SequenceEnumerator
extends java.lang.Object
implements SequenceEnumeration

Class which implements the SequenceEnumeration-interface. If this class was constructed giving a SequenceReader, the Sequences are extracted from it. If it was constructed giving a single Sequence, then only that sequence is supplied by calling nextSequence() for the first time, and every other call to nextSequence() will throw an exception.

See Also:
SequenceReader, SequenceEnumeration, Sequence

Field Summary
private  int actSequenceInFile
          Holds the counter of the sequence.
private  SequenceReader seqReader
          The underlying Reader from which the sequences are to send out.
private  Sequence sequ
          If this variable is not null, it is returned and the seqReader variable is not used.
 
Constructor Summary
SequenceEnumerator(Sequence sequ)
          Constructor.
SequenceEnumerator(SequenceReader seqReader)
          Constructor.
 
Method Summary
 Sequence nextSequence()
          Gos through the underlying stream for the next Sequence to return.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actSequenceInFile

private int actSequenceInFile
Holds the counter of the sequence.


seqReader

private SequenceReader seqReader
The underlying Reader from which the sequences are to send out.


sequ

private Sequence sequ
If this variable is not null, it is returned and the seqReader variable is not used.

Constructor Detail

SequenceEnumerator

public SequenceEnumerator(SequenceReader seqReader)
Constructor. Gets a SequenceReader object which writes SequenceInformationBlocks to distinguish single sequences from each other.

Parameters:
seqReader - The Reader from which the single sequences are to be obtained.
Throws:
java.lang.NullPointerException - If seqReader is null
See Also:
SequenceReader

SequenceEnumerator

public SequenceEnumerator(Sequence sequ)
Constructor. Gets only a Sequence which is the only object returned when calls to nextSequence() are performed.

Parameters:
sequ - The Sequence from which the single sequences are to be obtained.
Throws:
java.lang.NullPointerException - If sequ is null
See Also:
Sequence
Method Detail

nextSequence

public Sequence nextSequence()
                      throws NoMoreSequencesAvailableException
Description copied from interface: SequenceEnumeration
Gos through the underlying stream for the next Sequence to return. If no one could be found, a NoMoreSequencesAvailableException is thrown.

Specified by:
nextSequence in interface SequenceEnumeration
Returns:
A Sequence.
Throws:
NoMoreSequencesAvailableException - If no more sequence was found in the Reader.