| 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 | public static LanguageString NewInstance(String text, Language language){ |
|---|
| 41 | return new LanguageString(text, language); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | protected LanguageString() { |
|---|
| 45 | super(); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | protected LanguageString(String text, Language language) { |
|---|
| 49 | super(text, language); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | /* (non-Javadoc) |
|---|
| 53 | * @see eu.etaxonomy.cdm.model.common.CdmBase#toString() |
|---|
| 54 | */ |
|---|
| 55 | @Override |
|---|
| 56 | public String toString() { |
|---|
| 57 | if (text == null){ |
|---|
| 58 | return super.toString() + "null"; |
|---|
| 59 | }else{ |
|---|
| 60 | String languagePart = ""; |
|---|
| 61 | if (this.language != null){ |
|---|
| 62 | languagePart = "(" + this.language.toString() + ")"; |
|---|
| 63 | } |
|---|
| 64 | if (text.length() > 20){ |
|---|
| 65 | return text.substring(0, 20) + "..." + languagePart; |
|---|
| 66 | }else{ |
|---|
| 67 | return text + languagePart; |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | @Override |
|---|
| 73 | public Object clone() throws CloneNotSupportedException { |
|---|
| 74 | LanguageString result = (LanguageString)super.clone(); |
|---|
| 75 | return result; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | } |
|---|