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