3 * Copyright (C) 2016 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.molecular
.io
;
12 import java
.util
.Iterator
;
13 import java
.util
.NoSuchElementException
;
15 import eu
.etaxonomy
.taxeditor
.molecular
.l10n
.Messages
;
20 * Iterator implementation used internally be {@link CDMSequenceMatrixAdapter}.
25 class SequenceIDIterator
implements Iterator
<String
> {
26 private boolean containsConsensus
;
27 private int singleReadPos
;
28 private int singleReadCount
;
32 * Creates a new instance of this class.
34 * @param singleReadCount the number of single read IDs to be returned by this iterator before the consensus sequence
36 public SequenceIDIterator(int singleReadCount
, boolean containsConsensus
) {
38 this.containsConsensus
= containsConsensus
;
39 this.singleReadCount
= singleReadCount
;
40 this.singleReadPos
= 0;
45 public boolean hasNext() {
46 return (singleReadPos
< singleReadCount
) || (containsConsensus
&& (singleReadPos
<= singleReadCount
));
51 public String
next() {
52 if (singleReadPos
< singleReadCount
) {
53 return CDMSequenceMatrixAdapter
.SINGLE_READ_SEQUENCE_ID_PREFIX
+ (singleReadPos
++);
55 else if (containsConsensus
&& (singleReadPos
== singleReadCount
)) {
57 return CDMSequenceMatrixAdapter
.CONSENSUS_SEQUENCE_ID
;
60 throw new NoSuchElementException(Messages
.SequenceIDIterator_NO_MORE_SEQUENCES
);
66 public void remove() {
67 throw new UnsupportedOperationException(Messages
.SequenceIDIterator_REMOVE_NOT_SUPPORTED
);