Project

General

Profile

Download (2.68 KB) Statistics
| Branch: | Tag: | Revision:
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
		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);
50
			    }else{
51
			        supportedCodes.add(code);
52
			    }
53
			}
54
		}
55
		return supportedCodes;
56
	}
57

    
58
	/**
59
	 * @param code
60
	 * @return
61
	 */
62
	private static boolean isSupported(NomenclaturalCode code) {
63
		if (code.equals(NomenclaturalCode.ICNAFP ) || code.equals(NomenclaturalCode.ICZN)) {
64
			return true;
65
		} else {
66
			return false;
67
		}
68
	}
69

    
70

    
71
	/**
72
	 * <p>getDescription</p>
73
	 *
74
	 * @param code a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
75
	 * @return a {@link java.lang.String} object.
76
	 */
77
	public static String getDescription(NomenclaturalCode code) {
78
		if (code.equals(NomenclaturalCode.ICNB)) {
79
			return "International Code of Nomenclature of Bacteria (ICNB)";
80
		}
81
		if (code.equals(NomenclaturalCode.ICNAFP )) {
82
			return "International Code of Botanical Nomenclature (ICNAFP )";
83
		}
84
		if (code.equals(NomenclaturalCode.ICNCP)) {
85
			return "International Code of Cultivated Plants (ICNCP)";
86
		}
87
		if (code.equals(NomenclaturalCode.ICZN)) {
88
			return "International Code of Zoological Nomenclature (ICZN)";
89
		}
90
		if (code.equals(NomenclaturalCode.ICVCN)) {
91
			return "International Code for Virus Classification and Nomenclature (ICVCN)";
92
		}
93
		return code.name();
94
	}
95

    
96
	/**
97
	 * <p>getDefaultCode</p>
98
	 *
99
	 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
100
	 */
101
	public static NomenclaturalCode getDefaultCode() {
102
		return NomenclaturalCode.ICNAFP ;
103
	}
104
}
(35-35/41)