JAXB annotations - first drop
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / Representation.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
13 import org.apache.log4j.Logger;
14 import javax.persistence.*;
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlRootElement;
19 import javax.xml.bind.annotation.XmlType;
20
21 /**
22 * workaround for enumerations
23 * @author m.doering
24 * @version 1.0
25 * @created 08-Nov-2007 13:06:49
26 */
27
28 @XmlAccessorType(XmlAccessType.FIELD)
29 @XmlType(name = "Representation", propOrder = {
30 "label",
31 "abbreviatedLabel"
32 })
33 @XmlRootElement(name = "Representation")
34 @Entity
35 public class Representation extends LanguageStringBase {
36 static Logger logger = Logger.getLogger(Representation.class);
37
38 @XmlElement(name = "Label")
39 private String label;
40
41 @XmlElement(name = "AbbreviatedLabel")
42 private String abbreviatedLabel;
43
44 /**
45 * @param text
46 * @param label
47 * @param lang
48 * @return
49 */
50 public static Representation NewInstance(String text, String label, String abbreviatedLabel, Language lang){
51 return new Representation(text, label, abbreviatedLabel, lang);
52 }
53
54 public Representation() {
55 super();
56 }
57 public Representation(String text, String label, String abbreviatedLabel, Language language) {
58 super(text, language);
59 this.label = label;
60 }
61
62
63 public String getLabel(){
64 return this.label;
65 }
66 public void setLabel(String label){
67 this.label = label;
68 }
69
70 public String getAbbreviatedLabel(){
71 return this.abbreviatedLabel;
72 }
73 public void setAbbreviatedLabel(String abbreviatedLabel){
74 this.abbreviatedLabel = abbreviatedLabel;
75 }
76
77 @Transient
78 public String getDescription(){
79 return getText();
80 }
81 protected void setDescription(String text) {
82 super.setText(text);
83 }
84
85
86 /*
87 * Overrides super.getText() only to document that here the Text attribute
88 * should be used for a larger description of the label.
89 */
90 @Override
91 @Transient
92 public String getText(){
93 return super.getText();
94 }
95
96
97 public String toString(){
98 // we dont need the language returned too, do we?
99 return getLabel();
100 // if(getLanguage()==null || getLanguage().getLabel()==null){
101 // return getLabel();
102 // }else{
103 // return getLabel()+"("+ getLanguage().getLabel()+")";
104 // }
105 }
106 }