1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Country;
26  import com.liferay.portal.model.CountrySoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="CountryModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>Country</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.Country
53   * @see com.liferay.portal.model.CountryModel
54   * @see com.liferay.portal.model.impl.CountryImpl
55   *
56   */
57  public class CountryModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "Country";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "countryId", new Integer(Types.BIGINT) },
61              
62  
63              { "name", new Integer(Types.VARCHAR) },
64              
65  
66              { "a2", new Integer(Types.VARCHAR) },
67              
68  
69              { "a3", new Integer(Types.VARCHAR) },
70              
71  
72              { "number_", new Integer(Types.VARCHAR) },
73              
74  
75              { "idd_", new Integer(Types.VARCHAR) },
76              
77  
78              { "active_", new Integer(Types.BOOLEAN) }
79          };
80      public static final String TABLE_SQL_CREATE = "create table Country (countryId LONG not null primary key,name VARCHAR(75) null,a2 VARCHAR(75) null,a3 VARCHAR(75) null,number_ VARCHAR(75) null,idd_ VARCHAR(75) null,active_ BOOLEAN)";
81      public static final String TABLE_SQL_DROP = "drop table Country";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portal.model.Country"),
87              true);
88  
89      public static Country toModel(CountrySoap soapModel) {
90          Country model = new CountryImpl();
91  
92          model.setCountryId(soapModel.getCountryId());
93          model.setName(soapModel.getName());
94          model.setA2(soapModel.getA2());
95          model.setA3(soapModel.getA3());
96          model.setNumber(soapModel.getNumber());
97          model.setIdd(soapModel.getIdd());
98          model.setActive(soapModel.getActive());
99  
100         return model;
101     }
102 
103     public static List<Country> toModels(CountrySoap[] soapModels) {
104         List<Country> models = new ArrayList<Country>(soapModels.length);
105 
106         for (CountrySoap soapModel : soapModels) {
107             models.add(toModel(soapModel));
108         }
109 
110         return models;
111     }
112 
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portal.model.Country"));
115 
116     public CountryModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _countryId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setCountryId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_countryId);
129     }
130 
131     public long getCountryId() {
132         return _countryId;
133     }
134 
135     public void setCountryId(long countryId) {
136         if (countryId != _countryId) {
137             _countryId = countryId;
138         }
139     }
140 
141     public String getName() {
142         return GetterUtil.getString(_name);
143     }
144 
145     public void setName(String name) {
146         if (((name == null) && (_name != null)) ||
147                 ((name != null) && (_name == null)) ||
148                 ((name != null) && (_name != null) && !name.equals(_name))) {
149             _name = name;
150         }
151     }
152 
153     public String getA2() {
154         return GetterUtil.getString(_a2);
155     }
156 
157     public void setA2(String a2) {
158         if (((a2 == null) && (_a2 != null)) || ((a2 != null) && (_a2 == null)) ||
159                 ((a2 != null) && (_a2 != null) && !a2.equals(_a2))) {
160             _a2 = a2;
161         }
162     }
163 
164     public String getA3() {
165         return GetterUtil.getString(_a3);
166     }
167 
168     public void setA3(String a3) {
169         if (((a3 == null) && (_a3 != null)) || ((a3 != null) && (_a3 == null)) ||
170                 ((a3 != null) && (_a3 != null) && !a3.equals(_a3))) {
171             _a3 = a3;
172         }
173     }
174 
175     public String getNumber() {
176         return GetterUtil.getString(_number);
177     }
178 
179     public void setNumber(String number) {
180         if (((number == null) && (_number != null)) ||
181                 ((number != null) && (_number == null)) ||
182                 ((number != null) && (_number != null) &&
183                 !number.equals(_number))) {
184             _number = number;
185         }
186     }
187 
188     public String getIdd() {
189         return GetterUtil.getString(_idd);
190     }
191 
192     public void setIdd(String idd) {
193         if (((idd == null) && (_idd != null)) ||
194                 ((idd != null) && (_idd == null)) ||
195                 ((idd != null) && (_idd != null) && !idd.equals(_idd))) {
196             _idd = idd;
197         }
198     }
199 
200     public boolean getActive() {
201         return _active;
202     }
203 
204     public boolean isActive() {
205         return _active;
206     }
207 
208     public void setActive(boolean active) {
209         if (active != _active) {
210             _active = active;
211         }
212     }
213 
214     public Country toEscapedModel() {
215         if (isEscapedModel()) {
216             return (Country)this;
217         }
218         else {
219             Country model = new CountryImpl();
220 
221             model.setNew(isNew());
222             model.setEscapedModel(true);
223 
224             model.setCountryId(getCountryId());
225             model.setName(HtmlUtil.escape(getName()));
226             model.setA2(HtmlUtil.escape(getA2()));
227             model.setA3(HtmlUtil.escape(getA3()));
228             model.setNumber(HtmlUtil.escape(getNumber()));
229             model.setIdd(HtmlUtil.escape(getIdd()));
230             model.setActive(getActive());
231 
232             model = (Country)Proxy.newProxyInstance(Country.class.getClassLoader(),
233                     new Class[] { Country.class },
234                     new ReadOnlyBeanHandler(model));
235 
236             return model;
237         }
238     }
239 
240     public Object clone() {
241         CountryImpl clone = new CountryImpl();
242 
243         clone.setCountryId(getCountryId());
244         clone.setName(getName());
245         clone.setA2(getA2());
246         clone.setA3(getA3());
247         clone.setNumber(getNumber());
248         clone.setIdd(getIdd());
249         clone.setActive(getActive());
250 
251         return clone;
252     }
253 
254     public int compareTo(Object obj) {
255         if (obj == null) {
256             return -1;
257         }
258 
259         CountryImpl country = (CountryImpl)obj;
260 
261         int value = 0;
262 
263         value = getName().compareTo(country.getName());
264 
265         if (value != 0) {
266             return value;
267         }
268 
269         return 0;
270     }
271 
272     public boolean equals(Object obj) {
273         if (obj == null) {
274             return false;
275         }
276 
277         CountryImpl country = null;
278 
279         try {
280             country = (CountryImpl)obj;
281         }
282         catch (ClassCastException cce) {
283             return false;
284         }
285 
286         long pk = country.getPrimaryKey();
287 
288         if (getPrimaryKey() == pk) {
289             return true;
290         }
291         else {
292             return false;
293         }
294     }
295 
296     public int hashCode() {
297         return (int)getPrimaryKey();
298     }
299 
300     private long _countryId;
301     private String _name;
302     private String _a2;
303     private String _a3;
304     private String _number;
305     private String _idd;
306     private boolean _active;
307 }