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