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
.SpecimenTypeDesignationStatus
;
15 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
22 public class SpecimenTypeParser
{
25 public static class TypeInfo
{
26 public SpecimenTypeDesignationStatus status
;
27 public String collectionString
;
28 public boolean notDesignated
;
32 * see also CentralAfricaFernsTaxonParser#handleTypeLocationPart
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]+)?";
39 public static SpecimenTypeDesignationStatus
parseSpecimenTypeStatus(String type
) throws UnknownCdmTypeException
{
40 //TODO also compare with NameTypeParser
43 if (StringUtils
.isBlank(type
)){
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 );
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();
71 String message
= "Type Status not supported: " + type
;
72 throw new UnknownCdmTypeException(message
);