2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Iterator
;
14 import java
.util
.List
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
26 * Retrieves the elements of a <code>Taxon</code>'s synonymy list, including misapplied names,
29 * Note: does not return an entry for the <code>Taxon</code> itself.
36 public class IterableSynonymyList
implements Iterable
<TaxonBase
> {
37 private static final Logger logger
= Logger
38 .getLogger(IterableSynonymyList
.class);
42 public IterableSynonymyList(Taxon taxon
) {
46 public Iterator
<TaxonBase
> iterator() {
47 return new TaxonIterator(taxon
);
50 class TaxonIterator
implements Iterator
<TaxonBase
> {
52 List
<TaxonBase
> synonymyList
;
55 public TaxonIterator(Taxon taxon
) {
56 synonymyList
= new ArrayList
<TaxonBase
>();
57 HomotypicalGroup homotypicGroup
= taxon
.getHomotypicGroup();
59 if (homotypicGroup
!= null) {
60 List
<Synonym
> homotypicSynonyms
= homotypicGroup
.getSynonymsInGroup(taxon
.getSec());
61 for (Synonym synonym
: homotypicSynonyms
) {
63 // Make sure synonym belongs to the taxon
64 if (synonym
.getAcceptedTaxa().contains(taxon
)) {
65 synonymyList
.add(synonym
);
70 List
<HomotypicalGroup
> heterotypicGroups
= taxon
.getHeterotypicSynonymyGroups();
71 for (HomotypicalGroup heterotypicGroup
: heterotypicGroups
) {
73 // Make sure this is not the taxon's homotypic group
74 if (!heterotypicGroup
.equals(homotypicGroup
)) {
76 List
<Synonym
> heterotypicSynonyms
= heterotypicGroup
.
77 getSynonymsInGroup(taxon
.getSec());
78 for (Synonym synonym
: heterotypicSynonyms
) {
80 // Make sure synonym belongs to the taxon
81 if (synonym
.getAcceptedTaxa().contains(taxon
)) {
82 synonymyList
.add(synonym
);
88 Set
<Taxon
> misappliedNames
= taxon
.getMisappliedNames();
89 for (Taxon misappliedName
: misappliedNames
) {
90 synonymyList
.add(misappliedName
);
95 public boolean hasNext() {
96 if (synonymyList
.size() == index
) {
102 public TaxonBase
next() {
103 TaxonBase next
= synonymyList
.get(index
);
108 public void remove() {}