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
.TaxonNameBase
;
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(TaxonNameBase name
){
33 return name
.getTitleCache();
37 * <p>getDisplayName</p>
39 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
40 * @return a {@link java.lang.String} object.
42 public static String
getDisplayName(TaxonBase
<?
> taxon
){
43 return getDisplayName(taxon
.getName());
47 * <p>getDisplayNameWithRef</p>
49 * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
50 * @return a {@link java.lang.String} object.
52 public static String
getDisplayNameWithRef(TaxonBase taxonBase
) {
53 TaxonNameBase name
= (TaxonNameBase
) HibernateProxyHelper
.deproxy(taxonBase
.getName());
55 String fullTitle
= name
.generateFullTitle();
56 if (fullTitle
!= null){ //should never be null
57 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.