merge-update from trunk
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / LanguageString.java
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.cdm.model.common;
11
12 import javax.persistence.Entity;
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlRootElement;
16 import javax.xml.bind.annotation.XmlType;
17
18 import org.apache.log4j.Logger;
19 import org.hibernate.envers.Audited;
20 import org.hibernate.search.annotations.Indexed;
21
22 /**
23 * This class is an instantiatable class for the base class {@link LanguageStringBase}.
24 * No further functionality is added.
25 * @author m.doering
26 * @version 1.0
27 * @created 08-Nov-2007 13:06:32
28 */
29 @XmlAccessorType(XmlAccessType.FIELD)
30 @XmlType(name = "LanguageString")
31 @XmlRootElement(name = "LanguageString")
32 @Entity
33 @Indexed(index = "eu.etaxonomy.cdm.model.common.LanguageString")
34 @Audited
35 public class LanguageString extends LanguageStringBase implements Cloneable {
36 private static final long serialVersionUID = -1502298496073201104L;
37 @SuppressWarnings("unused")
38 private static final Logger logger = Logger.getLogger(LanguageString.class);
39
40 //********************* FACTORY *******************************************/
41
42 public static LanguageString NewInstance(String text, Language language){
43 return new LanguageString(text, language);
44 }
45
46 // ********************* CONSTRUCTOR ********************************/
47
48 protected LanguageString() {
49 super();
50 }
51
52 protected LanguageString(String text, Language language) {
53 super(text, language);
54 }
55
56
57 //*************** TO STRING ***********************************/
58 @Override
59 public String toString() {
60 if (text == null){
61 return super.toString() + ":null";
62 }else{
63 String languagePart = "";
64 if (this.language != null){
65 languagePart = "(" + this.language.toString() + ")";
66 }
67 if (text.length() > 20){
68 return text.substring(0, 20) + "..." + languagePart;
69 }else{
70 return text + languagePart;
71 }
72 }
73 }
74
75 // ************************ CLONE ********************************/
76 @Override
77 public Object clone() throws CloneNotSupportedException {
78 LanguageString result = (LanguageString)super.clone();
79 return result;
80 }
81
82 }