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