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.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
13 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
17 * <p>NameHelper class.</p>
24 public class NameHelper
{
27 * <p>getDisplayName</p>
29 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
30 * @return a {@link java.lang.String} object.
32 public static String
getDisplayName(TaxonName name
){
33 return name
.getTitleCache();
37 * <p>getDisplayName</p>
39 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
40 * @return a {@link java.lang.String} object.
42 public static String
getDisplayNameCache(TaxonBase taxon
){
43 return taxon
.getName().getNameCache();
46 * <p>getDisplayName</p>
48 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
49 * @return a {@link java.lang.String} object.
51 public static String
getDisplayName(TaxonBase
<?
> taxon
){
52 return getDisplayName(taxon
.getName());
56 * <p>getDisplayNameWithRef</p>
58 * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
59 * @return a {@link java.lang.String} object.
61 public static String
getDisplayNameWithRef(TaxonBase taxonBase
) {
62 TaxonName name
= HibernateProxyHelper
.deproxy(taxonBase
.getName());
64 String fullTitle
= name
.generateFullTitle();
65 if (fullTitle
!= null){ //should never be null
66 fullTitle
= fullTitle
.replaceAll("(\\r|\\n|\\r\\n)", ""); //replaces LineBreaks, maybe we should include U+000C, U+0085, U+2028, U+2029 which are also linebreaks according to UNICODE stardard.