3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.strategy
.parser
;
12 import org
.apache
.commons
.lang
.StringUtils
;
14 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignationStatus
;
15 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
22 public class NameTypeParser
{
24 private static final String desigPattern
= "\\sdesig(\\.|nation)?";
27 * see also CentralAfricaFernsTaxonParser#handleTypeLocationPart
29 public static final String typeTypePattern
= "("+
31 "(original|present|subsequent)"+ desigPattern
+
32 "(subsequent monotypy|tautonomy)" +
37 public static NameTypeDesignationStatus
parseNameTypeStatus(String type
) throws UnknownCdmTypeException
{
38 if (StringUtils
.isBlank(type
)){
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();
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();
63 String message
= "Type Status not supported: " + type
;
64 throw new UnknownCdmTypeException(message
);