1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.model;
|
11
|
|
12
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
13
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
14
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
15
|
|
16
|
/**
|
17
|
* <p>NameHelper class.</p>
|
18
|
*
|
19
|
* @author p.ciardelli
|
20
|
* @author n.hoffmann
|
21
|
* @created 18.03.2009
|
22
|
* @version 1.0
|
23
|
*/
|
24
|
public class NameHelper {
|
25
|
|
26
|
/**
|
27
|
* <p>getDisplayName</p>
|
28
|
*
|
29
|
* @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
|
30
|
* @return a {@link java.lang.String} object.
|
31
|
*/
|
32
|
public static String getDisplayName(TaxonNameBase name){
|
33
|
return name.getTitleCache();
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* <p>getDisplayName</p>
|
38
|
*
|
39
|
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
40
|
* @return a {@link java.lang.String} object.
|
41
|
*/
|
42
|
public static String getDisplayName(TaxonBase<?> taxon){
|
43
|
return getDisplayName(taxon.getName());
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* <p>getDisplayNameWithRef</p>
|
48
|
*
|
49
|
* @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
50
|
* @return a {@link java.lang.String} object.
|
51
|
*/
|
52
|
public static String getDisplayNameWithRef(TaxonBase taxonBase) {
|
53
|
TaxonNameBase name = (TaxonNameBase) HibernateProxyHelper.deproxy(taxonBase.getName());
|
54
|
if (name != null) {
|
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.
|
58
|
}
|
59
|
return fullTitle;
|
60
|
}
|
61
|
return "";
|
62
|
}
|
63
|
}
|