3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
13 import java
.util
.HashMap
;
16 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
17 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
18 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
19 import eu
.etaxonomy
.taxeditor
.parser
.ParseHandler
;
20 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 * <p>NameCreator class.</p>
30 public class NameCreator
implements IEntityCreator
<TaxonNameBase
> {
33 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
36 public TaxonNameBase
createEntity(String text
) {
37 TaxonNameBase name
= PreferencesUtil
.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
38 name
.setTitleCache(text
);
43 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
46 public TaxonNameBase
createEntity(Object key
, String text
) {
47 return ParseHandler
.parseName(text
, (Rank
) key
);
51 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
54 * <p>getKeyLabelPairs</p>
56 * @return a {@link java.util.Map} object.
58 public Map
<Object
, String
> getKeyLabelPairs() {
59 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
60 for (Rank rank
: CdmStore
.getTermManager().getPreferredTerms(Rank
.class)) {
61 result
.put(rank
, rank
.getLabel());