P
- the implementing class of AlignmentModel
which will return the iterator
inherited from this classpublic abstract class AbstractSequenceIDIterator<P extends AlignmentModel> extends java.lang.Object implements java.util.Iterator<java.lang.String>
AlignmentModel
.
Besides the sequence provider this class needs another iterator as a constructor parameter which is
responsible for returning new IDs in the correct order. This class implements a remove method which
throws an UnsupportedOperationException
if the underlying data source does not allow writing
sequences and calls the remove methods of the specified iterator. Additionally it offers an abstract
method doRemove()
that allows the implementations of AlignmentModel
to perform
additional specific removal operations. When overwriting this method the ID that is currently removed
can be obtained by getCurrentID()
.
Constructor and Description |
---|
AbstractSequenceIDIterator(P model,
java.util.Iterator<java.lang.String> iterator)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doRemove()
Overwrite this method to perform implementation specific remove operations.
|
protected java.lang.String |
getCurrentID()
The ID that has been returned by this iterator by the last call of
next() . |
protected java.util.Iterator<java.lang.String> |
getIterator()
Returns the underlying iterator object.
|
protected P |
getModel()
Returns the sequence data provider that returned this iterator.
|
boolean |
hasNext() |
java.lang.String |
next() |
void |
remove()
Removes the current ID from the underlying iterator and calls
doRemove() . |
public AbstractSequenceIDIterator(P model, java.util.Iterator<java.lang.String> iterator)
model
- the provider that is going to return this iterator with one of its methodsiterator
- the underlying iterator that returns the sequence IDs in the correct orderprotected P getModel()
protected java.util.Iterator<java.lang.String> getIterator()
protected java.lang.String getCurrentID()
next()
.null
if next()
has never been called until nowpublic boolean hasNext()
hasNext
in interface java.util.Iterator<java.lang.String>
public java.lang.String next()
next
in interface java.util.Iterator<java.lang.String>
protected abstract void doRemove()
This method is called by remove()
if the underlying data source in writable for sequences.
The remove()
method of the underlying iterator has already been called before the call of
this method, therefore this method will not be executed, if an exception was thrown by
getIterator().remove()
.
public void remove()
doRemove()
.remove
in interface java.util.Iterator<java.lang.String>
java.lang.UnsupportedOperationException
- if next()
has not yet been called or the underlying
data source is not writable for sequences or the underlying iterator does not support this
operationIterator.remove()