Project

General

Profile

Download (2.02 KB) Statistics
| Branch: | Tag: | Revision:
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.TaxonName;
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(TaxonName name){
33
		return name.getTitleCache();
34
	}
35
	
36
	/**
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
	/**
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
	public static String getDisplayName(TaxonBase<?> taxon){
52
		return getDisplayName(taxon.getName());
53
	}
54
	
55
	/**
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
	public static String getDisplayNameWithRef(TaxonBase taxonBase) {
62
		TaxonName name = HibernateProxyHelper.deproxy(taxonBase.getName());
63
		if (name != null) {
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.
67
			}
68
			return fullTitle;
69
		}
70
		return "";
71
	}	
72
}
(34-34/41)