Project

General

Profile

Download (2.19 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.NameTypeDesignationStatus;
15
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
16

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

    
24
	private static final String desigPattern =  "\\sdesig(\\.|nation)?";
25
	
26
	/**
27
	 * see also CentralAfricaFernsTaxonParser#handleTypeLocationPart
28
	 */
29
	public static final String typeTypePattern = "("+ 
30
			"lecto(\\.|type)?+" +
31
			"(original|present|subsequent)"+ desigPattern +
32
			"(subsequent monotypy|tautonomy)" + 
33
			")";
34
	
35
	
36
	
37
	public static NameTypeDesignationStatus parseNameTypeStatus(String type) throws UnknownCdmTypeException {
38
		if (StringUtils.isBlank(type)){
39
			return null;
40
		}
41
		if (type.matches("(?i).*" + desigPattern)){
42
			if (type.matches("(?i)original" + desigPattern)){
43
				return NameTypeDesignationStatus.ORIGINAL_DESIGNATION();
44
			}else if (type.matches("(?i)present" + desigPattern)){
45
				return NameTypeDesignationStatus.PRESENT_DESIGNATION();
46
			}else if (type.matches("(?i)subsequent" + desigPattern)){
47
				return NameTypeDesignationStatus.SUBSEQUENT_DESIGNATION();
48
			}
49
			
50
		}else if(type.matches("(?i)subsequent monotypy")){
51
			return NameTypeDesignationStatus.SUBSEQUENT_MONOTYPY();
52
		}else if(type.matches("(?i)monotypy")){
53
			return NameTypeDesignationStatus.MONOTYPY();
54
		}else if(type.matches("(?i)tautonomy")){
55
			return NameTypeDesignationStatus.TAUTONYMY();
56
		}else if(type.matches("(?i)lectotype")){
57
			return NameTypeDesignationStatus.LECTOTYPE();
58
		}else if(type.matches("(?i)automatic")){
59
			return NameTypeDesignationStatus.AUTOMATIC();
60
		}else if(type.matches("(?i)not applicable")){
61
			return NameTypeDesignationStatus.NOT_APPLICABLE();
62
		}
63
		String message = "Type Status not supported: " + type;
64
		throw new UnknownCdmTypeException(message);
65
		
66
	}
67
}
(2-2/8)