1 |
e8409423
|
n.hoffmann
|
/**
|
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 |
9766a939
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.model;
|
11 |
e8409423
|
n.hoffmann
|
|
12 |
3fb05254
|
n.hoffmann
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
13 |
e3a4a3ff
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
14 |
e8409423
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
3be6ef3e
|
n.hoffmann
|
* <p>NameHelper class.</p>
|
18 |
|
|
*
|
19 |
e8409423
|
n.hoffmann
|
* @author p.ciardelli
|
20 |
|
|
* @author n.hoffmann
|
21 |
|
|
* @created 18.03.2009
|
22 |
|
|
* @version 1.0
|
23 |
|
|
*/
|
24 |
df60b579
|
n.hoffmann
|
public class NameHelper {
|
25 |
e8409423
|
n.hoffmann
|
|
26 |
3be6ef3e
|
n.hoffmann
|
/**
|
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 |
e3a4a3ff
|
Andreas Müller
|
public static String getDisplayName(TaxonName name){
|
33 |
e8409423
|
n.hoffmann
|
return name.getTitleCache();
|
34 |
|
|
}
|
35 |
|
|
|
36 |
4585a268
|
Katja Luther
|
/**
|
37 |
|
|
* <p>getDisplayName</p>
|
38 |
|
|
*
|
39 |
|
|
* @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
|
40 |
|
|
* @return a {@link java.lang.String} object.
|
41 |
|
|
*/
|
42 |
|
|
public static String getDisplayNameCache(TaxonBase taxon){
|
43 |
|
|
return taxon.getName().getNameCache();
|
44 |
|
|
}
|
45 |
3be6ef3e
|
n.hoffmann
|
/**
|
46 |
|
|
* <p>getDisplayName</p>
|
47 |
|
|
*
|
48 |
|
|
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
49 |
|
|
* @return a {@link java.lang.String} object.
|
50 |
|
|
*/
|
51 |
e380ba33
|
n.hoffmann
|
public static String getDisplayName(TaxonBase<?> taxon){
|
52 |
e8409423
|
n.hoffmann
|
return getDisplayName(taxon.getName());
|
53 |
|
|
}
|
54 |
|
|
|
55 |
3be6ef3e
|
n.hoffmann
|
/**
|
56 |
|
|
* <p>getDisplayNameWithRef</p>
|
57 |
|
|
*
|
58 |
|
|
* @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
59 |
|
|
* @return a {@link java.lang.String} object.
|
60 |
|
|
*/
|
61 |
e8409423
|
n.hoffmann
|
public static String getDisplayNameWithRef(TaxonBase taxonBase) {
|
62 |
e3a4a3ff
|
Andreas Müller
|
TaxonName name = HibernateProxyHelper.deproxy(taxonBase.getName());
|
63 |
e8409423
|
n.hoffmann
|
if (name != null) {
|
64 |
c9431ec7
|
Andreas Müller
|
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.
|
67 |
|
|
}
|
68 |
|
|
return fullTitle;
|
69 |
e8409423
|
n.hoffmann
|
}
|
70 |
|
|
return "";
|
71 |
61e364bb
|
n.hoffmann
|
}
|
72 |
e8409423
|
n.hoffmann
|
}
|