minor
[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 * @author m.doering
24 * @version 1.0
25 * @created 08-Nov-2007 13:06:32
26 */
27 @XmlAccessorType(XmlAccessType.FIELD)
28 @XmlType(name = "LanguageString")
29 @XmlRootElement(name = "LanguageString")
30 @Entity
31 @Indexed(index = "eu.etaxonomy.cdm.model.common.LanguageString")
32 @Audited
33 public class LanguageString extends LanguageStringBase implements Cloneable {
34 private static final long serialVersionUID = -1502298496073201104L;
35 @SuppressWarnings("unused")
36 private static final Logger logger = Logger.getLogger(LanguageString.class);
37
38 public static LanguageString NewInstance(String text, Language language){
39 return new LanguageString(text, language);
40 }
41
42 protected LanguageString() {
43 super();
44 }
45
46 protected LanguageString(String text, Language language) {
47 super(text, language);
48 }
49
50 /* (non-Javadoc)
51 * @see eu.etaxonomy.cdm.model.common.CdmBase#toString()
52 */
53 @Override
54 public String toString() {
55 if (text == null){
56 return super.toString() + "null";
57 }else{
58 String languagePart = "";
59 if (this.language != null){
60 languagePart = "(" + this.language.toString() + ")";
61 }
62 if (text.length() > 20){
63 return text.substring(0, 20) + "..." + languagePart;
64 }else{
65 return text + languagePart;
66 }
67 }
68 }
69
70 @Override
71 public Object clone() throws CloneNotSupportedException {
72 LanguageString result = (LanguageString)super.clone();
73 return result;
74 }
75
76 }