2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.common
;
12 import javax
.persistence
.Column
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.Lob
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.persistence
.MappedSuperclass
;
17 import javax
.persistence
.Transient
;
18 import javax
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlElement
;
21 import javax
.xml
.bind
.annotation
.XmlIDREF
;
22 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
23 import javax
.xml
.bind
.annotation
.XmlSeeAlso
;
24 import javax
.xml
.bind
.annotation
.XmlType
;
25 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
27 import org
.apache
.log4j
.Logger
;
28 import org
.hibernate
.annotations
.Cascade
;
29 import org
.hibernate
.annotations
.CascadeType
;
30 import org
.hibernate
.search
.annotations
.Field
;
31 import org
.hibernate
.search
.annotations
.FieldBridge
;
32 import org
.hibernate
.search
.annotations
.Index
;
33 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
35 import eu
.etaxonomy
.cdm
.hibernate
.search
.StripHtmlBridge
;
36 import eu
.etaxonomy
.cdm
.jaxb
.FormattedTextAdapter
;
43 @XmlAccessorType(XmlAccessType
.FIELD
)
44 @XmlType(name
= "LanguageStringBase", propOrder
= {
52 public abstract class LanguageStringBase
extends AnnotatableEntity
{
53 private static final long serialVersionUID
= -1892526642162438277L;
54 @SuppressWarnings("unused")
55 private static final Logger logger
= Logger
.getLogger(LanguageStringBase
.class);
57 @XmlElement(name
= "Text")
58 @XmlJavaTypeAdapter(FormattedTextAdapter
.class)
60 @Field(index
=Index
.TOKENIZED
)
61 @FieldBridge(impl
=StripHtmlBridge
.class)
63 protected String text
;
65 @XmlElement(name
= "Language")
67 @XmlSchemaType(name
= "IDREF")
68 @ManyToOne(fetch
= FetchType
.EAGER
)
69 @Cascade({CascadeType
.MERGE
})
71 protected Language language
;
73 protected LanguageStringBase() {
77 protected LanguageStringBase(String text
, Language language
) {
79 this.setLanguage(language
);
84 public Language
getLanguage(){
87 public void setLanguage(Language language
){
88 this.language
= language
;
91 public String
getText(){
95 public void setText(String text
) {
100 public String
getLanguageLabel(){
101 if (language
!= null){
102 return this.language
.getRepresentation(Language
.DEFAULT()).getLabel();
108 public String
getLanguageLabel(Language lang
){
109 if (language
!= null){
110 return this.language
.getRepresentation(lang
).getLabel();
117 public Object
clone() throws CloneNotSupportedException
{
118 LanguageStringBase result
= (LanguageStringBase
) super.clone();
119 //no changes to text and language
120 //result.setText(this.text);
121 //result.setLanguage(this.language);