1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.model;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.Arrays;
|
14
|
import java.util.List;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
17
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
18
|
|
19
|
/**
|
20
|
* <p>NomenclaturalCodeHelper class.</p>
|
21
|
*
|
22
|
* @author p.ciardelli
|
23
|
* @created 11.09.2009
|
24
|
* @version 1.0
|
25
|
*/
|
26
|
public class NomenclaturalCodeHelper {
|
27
|
|
28
|
/**
|
29
|
* <p>getAllCodes</p>
|
30
|
*
|
31
|
* @return a {@link java.util.List} object.
|
32
|
*/
|
33
|
public static List<NomenclaturalCode> getAllCodes() {
|
34
|
return Arrays.asList(NomenclaturalCode.values());
|
35
|
}
|
36
|
|
37
|
|
38
|
/**
|
39
|
* <p>getSupportedCodes</p>
|
40
|
*
|
41
|
* @return a {@link java.util.List} object.
|
42
|
*/
|
43
|
public static List<NomenclaturalCode> getSupportedCodes() {
|
44
|
List<NomenclaturalCode> supportedCodes = new ArrayList<NomenclaturalCode>();
|
45
|
for (NomenclaturalCode code : getAllCodes()) {
|
46
|
if (isSupported(code)) {
|
47
|
if (PreferencesUtil.getPreferredNomenclaturalCode(false).equals(code)){
|
48
|
supportedCodes.add(0, code);
|
49
|
}else{
|
50
|
supportedCodes.add(code);
|
51
|
}
|
52
|
}
|
53
|
}
|
54
|
return supportedCodes;
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* @param code
|
59
|
* @return
|
60
|
*/
|
61
|
private static boolean isSupported(NomenclaturalCode code) {
|
62
|
if (code.equals(NomenclaturalCode.ICNAFP ) || code.equals(NomenclaturalCode.ICZN)) {
|
63
|
return true;
|
64
|
} else {
|
65
|
return false;
|
66
|
}
|
67
|
}
|
68
|
|
69
|
|
70
|
/**
|
71
|
* <p>getDescription</p>
|
72
|
*
|
73
|
* @param code a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
74
|
* @return a {@link java.lang.String} object.
|
75
|
*/
|
76
|
public static String getDescription(NomenclaturalCode code) {
|
77
|
if (code.equals(NomenclaturalCode.ICNB)) {
|
78
|
return "International Code of Nomenclature of Bacteria (ICNB)";
|
79
|
}
|
80
|
if (code.equals(NomenclaturalCode.ICNAFP )) {
|
81
|
return "International Code of Botanical Nomenclature (ICNAFP )";
|
82
|
}
|
83
|
if (code.equals(NomenclaturalCode.ICNCP)) {
|
84
|
return "International Code of Cultivated Plants (ICNCP)";
|
85
|
}
|
86
|
if (code.equals(NomenclaturalCode.ICZN)) {
|
87
|
return "International Code of Zoological Nomenclature (ICZN)";
|
88
|
}
|
89
|
if (code.equals(NomenclaturalCode.ICVCN)) {
|
90
|
return "International Code for Virus Classification and Nomenclature (ICVCN)";
|
91
|
}
|
92
|
return code.name();
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* <p>getDefaultCode</p>
|
97
|
*
|
98
|
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
99
|
*/
|
100
|
public static NomenclaturalCode getDefaultCode() {
|
101
|
return NomenclaturalCode.ICNAFP ;
|
102
|
}
|
103
|
}
|