View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  /**
24   *
25   */
26  package com.gisgraphy.domain.geoloc.entity;
27  
28  import javax.persistence.Column;
29  import javax.persistence.Entity;
30  import javax.persistence.GeneratedValue;
31  import javax.persistence.GenerationType;
32  import javax.persistence.Id;
33  import javax.persistence.SequenceGenerator;
34  
35  import org.hibernate.annotations.Cache;
36  import org.hibernate.annotations.CacheConcurrencyStrategy;
37  import org.hibernate.annotations.Index;
38  
39  /**
40   * Represents a spoken language
41   * 
42   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
43   * @see <a href="http://en.wikipedia.org/wiki/List_of_languages">List Of
44   *      Languages</a>
45   */
46  @Entity
47  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
48  @SequenceGenerator(name = "languageSequence", sequenceName = "language_id_seq")
49  public class Language {
50  
51      /**
52       * @see #getId()
53       */
54      private Long id;
55  
56      /**
57       * @see #getIso639Alpha2LanguageCode()
58       */
59      private String iso639Alpha2LanguageCode;
60  
61      /**
62       * @see #getIso639Alpha3LanguageCode()
63       */
64      private String iso639Alpha3LanguageCode;
65  
66      /**
67       * @see #getIso639LanguageName()
68       */
69      private String iso639LanguageName;
70  
71      public Language() {
72  	super();
73      }
74  
75      /**
76       * @param iso639LanguageName
77       *                The iso 639 Language name for the current language
78       * @param iso639Alpha2LanguageCode
79       *                The iso 639 alpha-2 code for the current language
80       * @param iso639Alpha3LanguageCode
81       *                The iso 639 alpha-3 code for the current language
82       */
83      public Language(String iso639LanguageName, String iso639Alpha2LanguageCode,
84  	    String iso639Alpha3LanguageCode) {
85  	super();
86  
87  	this.iso639LanguageName = iso639LanguageName;
88  	this.iso639Alpha2LanguageCode = iso639Alpha2LanguageCode;
89  	this.iso639Alpha3LanguageCode = iso639Alpha3LanguageCode;
90      }
91  
92      /**
93       * @return the datastore ID, it is not a domain value, just a technical one
94       */
95      @Id
96      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "languageSequence")
97      public Long getId() {
98  	return this.id;
99      }
100 
101     /**
102      * @return The iso 639 Alpha-2 letter code, if available
103      */
104     @Column(unique = true, nullable = true)
105     @Index(name = "iso639Alpha2LanguageCode")
106     public String getIso639Alpha2LanguageCode() {
107 	return this.iso639Alpha2LanguageCode;
108     }
109 
110     /**
111      * @return ISO-3 lettter code. Must be present
112      */
113     @Column(unique = true, nullable = false)
114     @Index(name = "iso639Alpha3LanguageCode")
115     public String getIso639Alpha3LanguageCode() {
116 	return this.iso639Alpha3LanguageCode;
117     }
118 
119     /**
120      * @return official ISO 639 name
121      */
122     @Column(unique = false, nullable = false)
123     public String getIso639LanguageName() {
124 	return this.iso639LanguageName;
125     }
126 
127     /**
128      * @param id
129      *                The datastore id. You should never call this method. It is
130      *                the responsibility of the dataStore
131      * @see #getId()
132      */
133     public void setId(Long id) {
134 	this.id = id;
135     }
136 
137     /**
138      * @see #getIso639Alpha2LanguageCode()
139      * @param iso639Alpha2LanguageCode
140      */
141     public void setIso639Alpha2LanguageCode(String iso639Alpha2LanguageCode) {
142 	this.iso639Alpha2LanguageCode = iso639Alpha2LanguageCode;
143     }
144 
145     /**
146      * @see #getIso639Alpha3LanguageCode()
147      * @param iso639Alpha3LanguageCode
148      */
149     public void setIso639Alpha3LanguageCode(String iso639Alpha3LanguageCode) {
150 	this.iso639Alpha3LanguageCode = iso639Alpha3LanguageCode;
151     }
152 
153     /**
154      * @see #getIso639LanguageName()
155      * @param iso639LanguageName
156      */
157     public void setIso639LanguageName(String iso639LanguageName) {
158 	this.iso639LanguageName = iso639LanguageName;
159     }
160 }