2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.strategy
.cache
.name
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
18 import eu
.etaxonomy
.cdm
.common
.UTF8
;
19 import eu
.etaxonomy
.cdm
.model
.agent
.INomenclaturalAuthor
;
20 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.name
.INonViralName
;
22 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
24 import eu
.etaxonomy
.cdm
.strategy
.cache
.TagEnum
;
25 import eu
.etaxonomy
.cdm
.strategy
.cache
.TaggedText
;
26 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
27 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImplRegExBase
;
31 * This class is a default implementation for the INonViralNameCacheStrategy<T extends NonViralName>
33 * The method implements a cache strategy for botanical names so no method has to be overwritten by
34 * a subclass for botanic names.
35 * Where differing from this default botanic name strategy other subclasses should overwrite the
36 * existing methods, e.g. a CacheStrategy for zoological names should overwrite getAuthorAndExAuthor
39 public class TaxonNameDefaultCacheStrategy
40 extends NameCacheStrategyBase
41 implements INonViralNameCacheStrategy
{
43 private static final Logger logger
= Logger
.getLogger(TaxonNameDefaultCacheStrategy
.class);
44 private static final long serialVersionUID
= -6577757501563212669L;
46 final static UUID uuid
= UUID
.fromString("1cdda0d1-d5bc-480f-bf08-40a510a2f223");
48 protected String nameAuthorSeperator
= " ";
49 protected String basionymStart
= "(";
50 protected String basionymEnd
= ")";
51 protected String exAuthorSeperator
= " ex ";
52 private static String NOTHO
= "notho";
53 protected CharSequence basionymAuthorCombinationAuthorSeperator
= " ";
55 protected String zooAuthorYearSeperator
= ", ";
58 public UUID
getUuid(){
62 // ************************** FACTORY ******************************/
64 public static TaxonNameDefaultCacheStrategy
NewInstance(){
65 return new TaxonNameDefaultCacheStrategy();
69 // ************ CONSTRUCTOR *******************/
71 protected TaxonNameDefaultCacheStrategy(){
75 /* **************** GETTER / SETTER **************************************/
78 * String that separates the NameCache part from the AuthorCache part
81 public String
getNameAuthorSeperator() {
82 return nameAuthorSeperator
;
84 public void setNameAuthorSeperator(String nameAuthorSeperator
) {
85 this.nameAuthorSeperator
= nameAuthorSeperator
;
90 * String the basionym author part starts with e.g. '('.
91 * This should correspond with the {@link TaxonNameDefaultCacheStrategy#getBasionymEnd() basionymEnd} attribute
94 public String
getBasionymStart() {
97 public void setBasionymStart(String basionymStart
) {
98 this.basionymStart
= basionymStart
;
102 * String the basionym author part ends with e.g. ')'.
103 * This should correspond with the {@link TaxonNameDefaultCacheStrategy#getBasionymStart() basionymStart} attribute
106 public String
getBasionymEnd() {
109 public void setBasionymEnd(String basionymEnd
) {
110 this.basionymEnd
= basionymEnd
;
115 * String to separate ex author from author.
118 public String
getExAuthorSeperator() {
119 return exAuthorSeperator
;
121 public void setExAuthorSeperator(String exAuthorSeperator
) {
122 this.exAuthorSeperator
= exAuthorSeperator
;
127 * String that separates the basionym/original_combination author part from the combination author part
130 public CharSequence
getBasionymAuthorCombinationAuthorSeperator() {
131 return basionymAuthorCombinationAuthorSeperator
;
135 public void setBasionymAuthorCombinationAuthorSeperator( CharSequence basionymAuthorCombinationAuthorSeperator
) {
136 this.basionymAuthorCombinationAuthorSeperator
= basionymAuthorCombinationAuthorSeperator
;
139 public String
getZooAuthorYearSeperator() {
140 return zooAuthorYearSeperator
;
142 public void setZooAuthorYearSeperator(String authorYearSeperator
) {
143 this.zooAuthorYearSeperator
= authorYearSeperator
;
146 // ******************* Authorship ******************************/
149 public String
getAuthorshipCache(TaxonName taxonName
) {
150 if (taxonName
== null){
152 }else if (taxonName
.getNameType().isViral()){
154 }else if(taxonName
.isProtectedAuthorshipCache() == true) {
156 return taxonName
.getAuthorshipCache();
158 return getNonCacheAuthorshipCache(taxonName
);
163 * Returns the authorshipcache string for the atomized authorship fields. Does not use the authorship field.
164 * @throws NullPointerException if nonViralName is null.
168 protected String
getNonCacheAuthorshipCache(TaxonName nonViralName
){
169 if (nonViralName
.getNameType().isZoological()){
170 return this.getZoologicalNonCacheAuthorshipCache(nonViralName
);
173 INomenclaturalAuthor combinationAuthor
= nonViralName
.getCombinationAuthorship();
174 INomenclaturalAuthor exCombinationAuthor
= nonViralName
.getExCombinationAuthorship();
175 INomenclaturalAuthor basionymAuthor
= nonViralName
.getBasionymAuthorship();
176 INomenclaturalAuthor exBasionymAuthor
= nonViralName
.getExBasionymAuthorship();
177 String basionymPart
= "";
178 String authorPart
= "";
180 if (basionymAuthor
!= null || exBasionymAuthor
!= null){
181 basionymPart
= basionymStart
+ getAuthorAndExAuthor(basionymAuthor
, exBasionymAuthor
) + basionymEnd
;
183 if (combinationAuthor
!= null || exCombinationAuthor
!= null){
184 authorPart
= getAuthorAndExAuthor(combinationAuthor
, exCombinationAuthor
);
186 result
= CdmUtils
.concat(basionymAuthorCombinationAuthorSeperator
, basionymPart
, authorPart
);
187 // if ("".equals(result)){
194 protected String
getZoologicalNonCacheAuthorshipCache(TaxonName nonViralName
) {
195 if (nonViralName
== null){
199 INomenclaturalAuthor combinationAuthor
= nonViralName
.getCombinationAuthorship();
200 INomenclaturalAuthor exCombinationAuthor
= nonViralName
.getExCombinationAuthorship();
201 INomenclaturalAuthor basionymAuthor
= nonViralName
.getBasionymAuthorship();
202 INomenclaturalAuthor exBasionymAuthor
= nonViralName
.getExBasionymAuthorship();
203 Integer publicationYear
= nonViralName
.getPublicationYear();
204 Integer originalPublicationYear
= nonViralName
.getOriginalPublicationYear();
206 String basionymPart
= "";
207 String authorPart
= "";
209 if (basionymAuthor
!= null || exBasionymAuthor
!= null || originalPublicationYear
!= null ){
210 String authorAndEx
= getAuthorAndExAuthor(basionymAuthor
, exBasionymAuthor
);
211 String originalPublicationYearString
= originalPublicationYear
== null ?
null : String
.valueOf(originalPublicationYear
);
212 String authorAndExAndYear
= CdmUtils
.concat(zooAuthorYearSeperator
, authorAndEx
, originalPublicationYearString
);
213 basionymPart
= basionymStart
+ authorAndExAndYear
+ basionymEnd
;
215 if (combinationAuthor
!= null || exCombinationAuthor
!= null){
216 String authorAndEx
= getAuthorAndExAuthor(combinationAuthor
, exCombinationAuthor
);
217 String publicationYearString
= publicationYear
== null ?
null : String
.valueOf(publicationYear
);
218 authorPart
= CdmUtils
.concat(zooAuthorYearSeperator
, authorAndEx
, publicationYearString
);
220 result
= CdmUtils
.concat(basionymAuthorCombinationAuthorSeperator
, basionymPart
, authorPart
);
229 * Returns the AuthorCache part for a combination of an author and an ex author. This applies on
230 * combination authors as well as on basionym/orginal combination authors.
231 * The correct order is exAuthor ex author though some botanist do not know about and do it the
232 * other way round. (see 46.4-46.6 ICBN (Vienna Code, 2006))
234 * @param author the author
235 * @param exAuthor the ex-author
238 protected String
getAuthorAndExAuthor(INomenclaturalAuthor author
, INomenclaturalAuthor exAuthor
){
239 String authorString
= "";
240 String exAuthorString
= "";
242 authorString
= CdmUtils
.Nz(author
.getNomenclaturalTitle());
244 if (exAuthor
!= null){
245 exAuthorString
= CdmUtils
.Nz(exAuthor
.getNomenclaturalTitle());
246 exAuthorString
+= exAuthorSeperator
;
248 String result
= exAuthorString
+ authorString
;
255 * Checks if the given name should include the author in it's cached version.<BR>
256 * This is usually the case but not for <i>species aggregates</i>.
257 * @param nonViralName
260 protected boolean nameIncludesAuthorship(INonViralName nonViralName
){
261 Rank rank
= nonViralName
.getRank();
262 if (rank
!= null && rank
.isSpeciesAggregate()){
269 // ************* TAGGED NAME ***************************************/
272 protected List
<TaggedText
> doGetTaggedTitle(TaxonName taxonName
) {
273 List
<TaggedText
> tags
= new ArrayList
<>();
274 if (taxonName
.getNameType().isViral()){
275 String acronym
= taxonName
.getAcronym();
276 if (isNotBlank(taxonName
.getAcronym())){
277 //this is not according to the code
278 tags
.add(new TaggedText(TagEnum
.name
, acronym
));
281 }else if (taxonName
.isHybridFormula()){
283 String hybridSeparator
= NonViralNameParserImplRegExBase
.hybridSign
;
284 boolean isFirst
= true;
285 List
<HybridRelationship
> rels
= taxonName
.getOrderedChildRelationships();
286 for (HybridRelationship rel
: rels
){
288 tags
.add(new TaggedText(TagEnum
.hybridSign
, hybridSeparator
));
291 tags
.addAll(getTaggedTitle(rel
.getParentName()));
294 }else if (taxonName
.isAutonym()){
296 tags
.addAll(handleTaggedAutonym(taxonName
));
298 List
<TaggedText
> nameTags
= getTaggedName(taxonName
);
299 tags
.addAll(nameTags
);
300 String authorCache
= getAuthorshipCache(taxonName
);
301 if (isNotBlank(authorCache
)){
302 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
309 * Returns the tag list of the name part (without author and reference).
314 public List
<TaggedText
> getTaggedName(TaxonName taxonName
) {
315 if (taxonName
== null){
317 }else if (taxonName
.isViral()){
320 List
<TaggedText
> tags
= new ArrayList
<>();
321 Rank rank
= taxonName
.getRank();
323 if (taxonName
.isProtectedNameCache()){
324 tags
.add(new TaggedText(TagEnum
.name
, taxonName
.getNameCache()));
325 }else if (taxonName
.isHybridFormula()){
327 String hybridSeparator
= NonViralNameParserImplRegExBase
.hybridSign
;
328 boolean isFirst
= true;
329 List
<HybridRelationship
> rels
= taxonName
.getOrderedChildRelationships();
330 for (HybridRelationship rel
: rels
){
332 tags
.add(new TaggedText(TagEnum
.hybridSign
, hybridSeparator
));
335 tags
.addAll(getTaggedName(rel
.getParentName()));
339 }else if (rank
== null){
340 tags
= getRanklessTaggedNameCache(taxonName
);
341 // }else if (nonViralName.isInfragenericUnranked()){
342 // result = getUnrankedInfragenericNameCache(nonViralName);
343 }else if (rank
.isInfraSpecific()){
344 tags
= getInfraSpeciesTaggedNameCache(taxonName
);
345 }else if (rank
.isSpecies() || isAggregateWithAuthorship(taxonName
, rank
) ){ //exception see #4288
346 tags
= getSpeciesTaggedNameCache(taxonName
);
347 }else if (rank
.isInfraGeneric()){
348 tags
= getInfraGenusTaggedNameCache(taxonName
);
349 }else if (rank
.isGenus()){
350 tags
= getGenusOrUninomialTaggedNameCache(taxonName
);
351 }else if (rank
.isSupraGeneric()){
352 tags
= getGenusOrUninomialTaggedNameCache(taxonName
);
354 tags
= getRanklessTaggedNameCache(taxonName
);
355 logger
.warn("Rank does not belong to a rank class: " + rank
.getTitleCache() + ". Used rankless nameCache for name " + taxonName
.getUuid());
357 //TODO handle appended phrase here instead of different places, check first if this is true for all
363 //***************************** PRIVATES ***************************************/
365 private boolean isAggregateWithAuthorship(TaxonName nonViralName
, Rank rank
) {
369 return rank
.isSpeciesAggregate() && ( isNotBlank(nonViralName
.getAuthorshipCache()) || nonViralName
.getNomenclaturalReference() != null );
374 * Returns the tag list for an autonym taxon.
376 * @see NonViralName#isAutonym()
377 * @see BotanicalName#isAutonym()
378 * @param nonViralName
381 private List
<TaggedText
> handleTaggedAutonym(TaxonName nonViralName
) {
382 List
<TaggedText
> tags
= null;
383 if (nonViralName
.isInfraSpecific()){
385 tags
= getSpeciesTaggedNameCache(nonViralName
);
388 String authorCache
= getAuthorshipCache(nonViralName
);
389 if (isNotBlank(authorCache
)){
390 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
393 //infra species marker
394 if (nonViralName
.getRank() == null || !nonViralName
.getRank().isInfraSpecific()){
395 //TODO handle exception
396 logger
.warn("Rank for autonym does not exist or is not lower than species !!");
398 String infraSpeciesMarker
= nonViralName
.getRank().getAbbreviation();
399 if (nonViralName
.isTrinomHybrid()){
400 infraSpeciesMarker
= CdmUtils
.concat("", NOTHO
, infraSpeciesMarker
);
402 if (isNotBlank(infraSpeciesMarker
)){
403 tags
.add(new TaggedText(TagEnum
.rank
, infraSpeciesMarker
));
408 String infraSpeciesPart
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet()).trim();
409 if (isNotBlank(infraSpeciesPart
)){
410 tags
.add(new TaggedText(TagEnum
.name
, infraSpeciesPart
));
413 } else if (nonViralName
.isInfraGeneric()){
415 tags
=getGenusOrUninomialTaggedNameCache(nonViralName
);
418 String authorCache
= getAuthorshipCache(nonViralName
);
419 if (isNotBlank(authorCache
)){
420 tags
.add(new TaggedText(TagEnum
.authors
, authorCache
));
423 //infra species marker
424 if (nonViralName
.getRank() == null || !nonViralName
.getRank().isInfraGeneric()){
425 //TODO handle exception
426 logger
.warn("Rank for autonym does not exist or is not lower than species !!");
428 Rank rank
= nonViralName
.getRank();
429 String infraGenericMarker
= rank
.getAbbreviation();
430 if (rank
.equals(Rank
.SECTION_BOTANY()) || rank
.equals(Rank
.SUBSECTION_BOTANY())){
431 infraGenericMarker
= infraGenericMarker
.replace("(bot.)", "");
433 if (isNotBlank(infraGenericMarker
)){
434 tags
.add(new TaggedText(TagEnum
.rank
, infraGenericMarker
));
439 String infraGenericPart
= CdmUtils
.Nz(nonViralName
.getInfraGenericEpithet()).trim();
440 if (isNotBlank(infraGenericPart
)){
441 tags
.add(new TaggedText(TagEnum
.name
, infraGenericPart
));
451 * Returns the tag list for rankless taxa.
452 * @param nonViralName
455 protected List
<TaggedText
> getRanklessTaggedNameCache(INonViralName nonViralName
){
456 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
457 String speciesEpi
= CdmUtils
.Nz(nonViralName
.getSpecificEpithet()).trim();
458 if (isNotBlank(speciesEpi
)){
459 tags
.add(new TaggedText(TagEnum
.name
, speciesEpi
));
462 String infraSpeciesEpi
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet());
463 if (isNotBlank(infraSpeciesEpi
)){
464 tags
.add(new TaggedText(TagEnum
.name
, infraSpeciesEpi
));
467 //result += " (rankless)";
468 addAppendedTaggedPhrase(tags
, nonViralName
);
473 * Returns the tag list for the first epithet (including a hybrid sign if required).
474 * @param nonViralName
477 private List
<TaggedText
> getUninomialTaggedPart(INonViralName nonViralName
) {
478 List
<TaggedText
> tags
= new ArrayList
<>();
480 if (nonViralName
.isMonomHybrid()){
481 addHybridPrefix(tags
);
484 String uninomial
= CdmUtils
.Nz(nonViralName
.getGenusOrUninomial()).trim();
485 if (isNotBlank(uninomial
)){
486 tags
.add(new TaggedText(TagEnum
.name
, uninomial
));
493 * Returns the tag list for an genus or higher taxon.
495 * @param nonViralName
498 protected List
<TaggedText
> getGenusOrUninomialTaggedNameCache(INonViralName nonViralName
){
499 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
500 addAppendedTaggedPhrase(tags
, nonViralName
);
505 * Returns the tag list for an infrageneric taxon (including species aggregates).
507 * @see #getSpeciesAggregateTaggedCache(NonViralName)
508 * @param nonViralName
511 protected List
<TaggedText
> getInfraGenusTaggedNameCache(INonViralName nonViralName
){
512 Rank rank
= nonViralName
.getRank();
513 if (rank
!= null && rank
.isSpeciesAggregate() && isBlank(nonViralName
.getAuthorshipCache())){
514 return getSpeciesAggregateTaggedCache(nonViralName
);
518 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
521 String infraGenericMarker
;
524 infraGenericMarker
= rank
.getInfraGenericMarker();
525 if (rank
.equals(Rank
.SECTION_BOTANY()) || rank
.equals(Rank
.SUBSECTION_BOTANY())){
526 infraGenericMarker
= infraGenericMarker
.replace("(bot.)", "");
528 } catch (UnknownCdmTypeException e
) {
529 infraGenericMarker
= "'unhandled infrageneric rank'";
532 infraGenericMarker
= "'undefined infrageneric rank'";
534 String infraGenEpi
= CdmUtils
.Nz(nonViralName
.getInfraGenericEpithet()).trim();
535 if (nonViralName
.isBinomHybrid()){
536 infraGenericMarker
= CdmUtils
.concat("", NOTHO
, infraGenericMarker
);
539 addInfraGenericPart(nonViralName
, tags
, infraGenericMarker
, infraGenEpi
);
541 addAppendedTaggedPhrase(tags
, nonViralName
);
547 * Default implementation for the infrageneric part of a name.
548 * This is usually the infrageneric marker and the infrageneric epitheton. But may be
549 * implemented differently e.g. for zoological names the infrageneric epitheton
550 * may be surrounded by brackets and the marker left out.
551 * @param nonViralName
553 * @param infraGenericMarker
555 protected void addInfraGenericPart(
556 @SuppressWarnings("unused") INonViralName name
,
557 List
<TaggedText
> tags
,
558 String infraGenericMarker
,
559 String infraGenEpi
) {
561 tags
.add(new TaggedText(TagEnum
.rank
, infraGenericMarker
));
564 if (isNotBlank(infraGenEpi
)){
565 tags
.add(new TaggedText(TagEnum
.name
, infraGenEpi
));
570 * Returns the tag list for a species aggregate (or similar) taxon.<BR>
571 * Possible ranks for a <i>species aggregate</i> are "aggr.", "species group", ...
572 * @param nonViralName
575 protected List
<TaggedText
> getSpeciesAggregateTaggedCache(INonViralName nonViralName
){
576 if (! isBlank(nonViralName
.getAuthorshipCache())){
577 List
<TaggedText
> result
= getSpeciesTaggedNameCache(nonViralName
);
582 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
584 addSpeciesAggregateTaggedEpithet(tags
, nonViralName
);
585 addAppendedTaggedPhrase(tags
, nonViralName
);
590 * Adds the aggregate tag to the tag list.
592 * @param nonViralName
594 private void addSpeciesAggregateTaggedEpithet(List
<TaggedText
> tags
, INonViralName nonViralName
) {
597 marker
= nonViralName
.getRank().getInfraGenericMarker();
598 } catch (UnknownCdmTypeException e
) {
599 marker
= "'unknown aggregat type'";
601 if (isNotBlank(marker
)){
602 tags
.add(new TaggedText(TagEnum
.rank
, marker
));
608 * Returns the tag list for a species taxon.
609 * @param nonViralName
612 protected List
<TaggedText
> getSpeciesTaggedNameCache(INonViralName nonViralName
){
613 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
614 addAppendedTaggedPhrase(tags
, nonViralName
);
618 protected List
<TaggedText
> getInfraSpeciesTaggedNameCache(TaxonName name
){
619 if (name
.getNameType().isZoological()){
620 boolean includeMarker
=includeInfraSpecificMarkerForZooNames(name
);
621 return getInfraSpeciesTaggedNameCache(name
, includeMarker
);
623 return getInfraSpeciesTaggedNameCache(name
, true);
627 protected boolean includeInfraSpecificMarkerForZooNames(TaxonName name
){
628 return ! (name
.isAutonym()); //only exclude marker if autonym, see also ZooNameNoMarkerCacheStrategy
632 * Creates the tag list for an infraspecific taxon. If include is true the result will contain
633 * the infraspecific marker (e.g. "var.")
634 * @param nonViralName
635 * @param includeMarker
638 protected List
<TaggedText
> getInfraSpeciesTaggedNameCache(INonViralName nonViralName
, boolean includeMarker
){
639 List
<TaggedText
> tags
= getGenusAndSpeciesTaggedPart(nonViralName
);
640 if (includeMarker
|| nonViralName
.isTrinomHybrid()){
641 String marker
= (nonViralName
.getRank().getAbbreviation()).trim().replace("null", "");
642 if (nonViralName
.isTrinomHybrid()){
643 marker
= CdmUtils
.concat("", NOTHO
, marker
);
645 if (isNotBlank(marker
)){
646 tags
.add(new TaggedText(TagEnum
.rank
, marker
));
650 String infrSpecEpi
= CdmUtils
.Nz(nonViralName
.getInfraSpecificEpithet());
652 infrSpecEpi
= infrSpecEpi
.trim().replace("null", "");
654 if (isNotBlank(infrSpecEpi
)){
655 tags
.add(new TaggedText(TagEnum
.name
, infrSpecEpi
));
658 addAppendedTaggedPhrase(tags
, nonViralName
);
664 * Adds a tag for the hybrid sign and an empty separator to avoid trailing whitespaces.
667 private void addHybridPrefix(List
<TaggedText
> tags
) {
668 tags
.add(new TaggedText(TagEnum
.hybridSign
, NonViralNameParserImplRegExBase
.hybridSign
));
669 tags
.add(new TaggedText(TagEnum
.separator
, "")); //no whitespace separator
673 * Creates the tag list for the genus and species part.
674 * @param nonViralName
677 private List
<TaggedText
> getGenusAndSpeciesTaggedPart(INonViralName nonViralName
) {
679 List
<TaggedText
> tags
= getUninomialTaggedPart(nonViralName
);
682 boolean hasInfraGenericEpi
= isNotBlank(nonViralName
.getInfraGenericEpithet());
683 if (hasInfraGenericEpi
){
684 String infrGenEpi
= nonViralName
.getInfraGenericEpithet().trim();
685 if (nonViralName
.isBinomHybrid()){
686 //maybe not correct but not really expected to happen
687 infrGenEpi
= UTF8
.HYBRID
+ infrGenEpi
;
689 infrGenEpi
= "(" + infrGenEpi
+ ")";
690 tags
.add(new TaggedText(TagEnum
.name
, infrGenEpi
));
694 String specEpi
= CdmUtils
.Nz(nonViralName
.getSpecificEpithet()).trim();
695 if (! hasInfraGenericEpi
&& nonViralName
.isBinomHybrid() ||
696 hasInfraGenericEpi
&& nonViralName
.isTrinomHybrid()){
697 addHybridPrefix(tags
);
699 if (isNotBlank(specEpi
)){
700 tags
.add(new TaggedText(TagEnum
.name
, specEpi
));
706 * Adds the tag for the appended phrase if an appended phrase exists
708 * @param nonViralName
710 protected void addAppendedTaggedPhrase(List
<TaggedText
> tags
, INonViralName nonViralName
){
711 String appendedPhrase
= nonViralName
==null ?
null : nonViralName
.getAppendedPhrase();
712 if (isNotBlank(appendedPhrase
)){
713 tags
.add(new TaggedText(TagEnum
.name
, appendedPhrase
));
718 public String
getLastEpithet(TaxonName taxonName
) {
719 Rank rank
= taxonName
.getRank();
720 if(rank
.isGenus() || rank
.isSupraGeneric()) {
721 return taxonName
.getGenusOrUninomial();
722 } else if(rank
.isInfraGeneric()) {
723 return taxonName
.getInfraGenericEpithet();
724 } else if(rank
.isSpecies()) {
725 return taxonName
.getSpecificEpithet();
727 return taxonName
.getInfraSpecificEpithet();