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
.model
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
17 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 * <p>NomenclaturalCodeHelper class.</p>
26 public class NomenclaturalCodeHelper
{
31 * @return a {@link java.util.List} object.
33 public static List
<NomenclaturalCode
> getAllCodes() {
34 return Arrays
.asList(NomenclaturalCode
.values());
39 * <p>getSupportedCodes</p>
41 * @return a {@link java.util.List} object.
43 public static List
<NomenclaturalCode
> getSupportedCodes() {
44 List
<NomenclaturalCode
> supportedCodes
= new ArrayList
<NomenclaturalCode
>();
45 NomenclaturalCode nomenclaturalCode
=PreferencesUtil
.getPreferredNomenclaturalCode();
46 for (NomenclaturalCode code
: getAllCodes()) {
47 if (isSupported(code
)) {
48 if (nomenclaturalCode
!= null && nomenclaturalCode
.equals(code
)){
49 supportedCodes
.add(0, code
);
51 supportedCodes
.add(code
);
55 return supportedCodes
;
62 private static boolean isSupported(NomenclaturalCode code
) {
63 if (code
.equals(NomenclaturalCode
.ICNAFP
) || code
.equals(NomenclaturalCode
.ICZN
)) {
72 * <p>getDescription</p>
74 * @param code a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
75 * @return a {@link java.lang.String} object.
77 public static String
getDescription(NomenclaturalCode code
) {
78 if (code
.equals(NomenclaturalCode
.ICNB
)) {
79 return "International Code of Nomenclature of Bacteria (ICNB)";
81 if (code
.equals(NomenclaturalCode
.ICNAFP
)) {
82 return "International Code of Botanical Nomenclature (ICNAFP )";
84 if (code
.equals(NomenclaturalCode
.ICNCP
)) {
85 return "International Code of Cultivated Plants (ICNCP)";
87 if (code
.equals(NomenclaturalCode
.ICZN
)) {
88 return "International Code of Zoological Nomenclature (ICZN)";
90 if (code
.equals(NomenclaturalCode
.ICVCN
)) {
91 return "International Code for Virus Classification and Nomenclature (ICVCN)";
97 * <p>getDefaultCode</p>
99 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
101 public static NomenclaturalCode
getDefaultCode() {
102 return NomenclaturalCode
.ICNAFP
;