Project

General

Profile

Download (2.56 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 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
package eu.etaxonomy.cdm.strategy.parser;
11

    
12
import org.apache.commons.lang.StringUtils;
13

    
14
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
15
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
16

    
17
/**
18
 * @author a.mueller
19
 * @date 25.07.2011
20
 *
21
 */
22
public class SpecimenTypeParser {
23

    
24

    
25
	public static class TypeInfo{
26
		public SpecimenTypeDesignationStatus status;
27
		public String collectionString;
28
		public boolean notDesignated;
29
	}
30
	
31
	/**
32
	 * see also CentralAfricaFernsTaxonParser#handleTypeLocationPart
33
	 */
34
	public static final String typeTypePattern = "(?i)(holo|lecto|iso|isolecto|syn|isosyn|neo|isoneo|type)\\.?";
35
	public static final String collectionPattern = "^[A-Z]+(\\-[A-Z]+)?";
36
	
37
	
38
	
39
	public static SpecimenTypeDesignationStatus parseSpecimenTypeStatus(String type) throws UnknownCdmTypeException {
40
		//TODO also compare with NameTypeParser
41
		//TODO further types
42
		
43
		if (StringUtils.isBlank(type)){
44
			return null;
45
		}else if (type.endsWith("type") && ! type.equalsIgnoreCase("type")){
46
			type = type.substring(0, type.length() -4 );
47
		}else if (type.endsWith("types") && ! type.equalsIgnoreCase("types")){
48
			type = type.substring(0, type.length() -5 );
49
		}
50
		
51
		SpecimenTypeDesignationStatus status; 
52
		if (type.equalsIgnoreCase("iso")){
53
			status = SpecimenTypeDesignationStatus.ISOTYPE();
54
		}else if (type.equalsIgnoreCase("isolecto")){
55
			status = SpecimenTypeDesignationStatus.ISOLECTOTYPE();
56
		}else if (type.equalsIgnoreCase("syn")){
57
			status = SpecimenTypeDesignationStatus.SYNTYPE();
58
		}else if (type.equalsIgnoreCase("holo")){
59
			status = SpecimenTypeDesignationStatus.HOLOTYPE();
60
		}else if (type.equalsIgnoreCase("lecto")){
61
			status = SpecimenTypeDesignationStatus.LECTOTYPE();
62
		}else if (type.equalsIgnoreCase("isosyn")){
63
			status = SpecimenTypeDesignationStatus.ISOSYNTYPE();
64
		}else if (type.equalsIgnoreCase("neo")){
65
			status = SpecimenTypeDesignationStatus.NEOTYPE();
66
		}else if (type.equalsIgnoreCase("isoneo")){
67
			status = SpecimenTypeDesignationStatus.ISONEOTYPE();
68
		}else if (type.equalsIgnoreCase("type")){
69
			status = SpecimenTypeDesignationStatus.TYPE();
70
		}else{
71
			String message = "Type Status not supported: " + type;
72
			throw new UnknownCdmTypeException(message);
73
		}
74
		return status;
75
	}
76
}
(6-6/8)