1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Country;
29  import com.liferay.portal.model.CountrySoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="CountryModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>Country</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.Country
56   * @see com.liferay.portal.model.CountryModel
57   * @see com.liferay.portal.model.impl.CountryImpl
58   *
59   */
60  public class CountryModelImpl extends BaseModelImpl<Country> {
61      public static final String TABLE_NAME = "Country";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "countryId", new Integer(Types.BIGINT) },
64              
65  
66              { "name", new Integer(Types.VARCHAR) },
67              
68  
69              { "a2", new Integer(Types.VARCHAR) },
70              
71  
72              { "a3", new Integer(Types.VARCHAR) },
73              
74  
75              { "number_", new Integer(Types.VARCHAR) },
76              
77  
78              { "idd_", new Integer(Types.VARCHAR) },
79              
80  
81              { "active_", new Integer(Types.BOOLEAN) }
82          };
83      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)";
84      public static final String TABLE_SQL_DROP = "drop table Country";
85      public static final String DATA_SOURCE = "liferayDataSource";
86      public static final String SESSION_FACTORY = "liferaySessionFactory";
87      public static final String TX_MANAGER = "liferayTransactionManager";
88      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.entity.cache.enabled.com.liferay.portal.model.Country"),
90              true);
91      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.finder.cache.enabled.com.liferay.portal.model.Country"),
93              true);
94  
95      public static Country toModel(CountrySoap soapModel) {
96          Country model = new CountryImpl();
97  
98          model.setCountryId(soapModel.getCountryId());
99          model.setName(soapModel.getName());
100         model.setA2(soapModel.getA2());
101         model.setA3(soapModel.getA3());
102         model.setNumber(soapModel.getNumber());
103         model.setIdd(soapModel.getIdd());
104         model.setActive(soapModel.getActive());
105 
106         return model;
107     }
108 
109     public static List<Country> toModels(CountrySoap[] soapModels) {
110         List<Country> models = new ArrayList<Country>(soapModels.length);
111 
112         for (CountrySoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portal.model.Country"));
121 
122     public CountryModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _countryId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setCountryId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_countryId);
135     }
136 
137     public long getCountryId() {
138         return _countryId;
139     }
140 
141     public void setCountryId(long countryId) {
142         _countryId = countryId;
143     }
144 
145     public String getName() {
146         return GetterUtil.getString(_name);
147     }
148 
149     public void setName(String name) {
150         _name = name;
151 
152         if (_originalName == null) {
153             _originalName = name;
154         }
155     }
156 
157     public String getOriginalName() {
158         return GetterUtil.getString(_originalName);
159     }
160 
161     public String getA2() {
162         return GetterUtil.getString(_a2);
163     }
164 
165     public void setA2(String a2) {
166         _a2 = a2;
167 
168         if (_originalA2 == null) {
169             _originalA2 = a2;
170         }
171     }
172 
173     public String getOriginalA2() {
174         return GetterUtil.getString(_originalA2);
175     }
176 
177     public String getA3() {
178         return GetterUtil.getString(_a3);
179     }
180 
181     public void setA3(String a3) {
182         _a3 = a3;
183 
184         if (_originalA3 == null) {
185             _originalA3 = a3;
186         }
187     }
188 
189     public String getOriginalA3() {
190         return GetterUtil.getString(_originalA3);
191     }
192 
193     public String getNumber() {
194         return GetterUtil.getString(_number);
195     }
196 
197     public void setNumber(String number) {
198         _number = number;
199     }
200 
201     public String getIdd() {
202         return GetterUtil.getString(_idd);
203     }
204 
205     public void setIdd(String idd) {
206         _idd = idd;
207     }
208 
209     public boolean getActive() {
210         return _active;
211     }
212 
213     public boolean isActive() {
214         return _active;
215     }
216 
217     public void setActive(boolean active) {
218         _active = active;
219     }
220 
221     public Country toEscapedModel() {
222         if (isEscapedModel()) {
223             return (Country)this;
224         }
225         else {
226             Country model = new CountryImpl();
227 
228             model.setNew(isNew());
229             model.setEscapedModel(true);
230 
231             model.setCountryId(getCountryId());
232             model.setName(HtmlUtil.escape(getName()));
233             model.setA2(HtmlUtil.escape(getA2()));
234             model.setA3(HtmlUtil.escape(getA3()));
235             model.setNumber(HtmlUtil.escape(getNumber()));
236             model.setIdd(HtmlUtil.escape(getIdd()));
237             model.setActive(getActive());
238 
239             model = (Country)Proxy.newProxyInstance(Country.class.getClassLoader(),
240                     new Class[] { Country.class },
241                     new ReadOnlyBeanHandler(model));
242 
243             return model;
244         }
245     }
246 
247     public Object clone() {
248         CountryImpl clone = new CountryImpl();
249 
250         clone.setCountryId(getCountryId());
251         clone.setName(getName());
252         clone.setA2(getA2());
253         clone.setA3(getA3());
254         clone.setNumber(getNumber());
255         clone.setIdd(getIdd());
256         clone.setActive(getActive());
257 
258         return clone;
259     }
260 
261     public int compareTo(Country country) {
262         int value = 0;
263 
264         value = getName().compareTo(country.getName());
265 
266         if (value != 0) {
267             return value;
268         }
269 
270         return 0;
271     }
272 
273     public boolean equals(Object obj) {
274         if (obj == null) {
275             return false;
276         }
277 
278         Country country = null;
279 
280         try {
281             country = (Country)obj;
282         }
283         catch (ClassCastException cce) {
284             return false;
285         }
286 
287         long pk = country.getPrimaryKey();
288 
289         if (getPrimaryKey() == pk) {
290             return true;
291         }
292         else {
293             return false;
294         }
295     }
296 
297     public int hashCode() {
298         return (int)getPrimaryKey();
299     }
300 
301     public String toString() {
302         StringBuilder sb = new StringBuilder();
303 
304         sb.append("{countryId=");
305         sb.append(getCountryId());
306         sb.append(", name=");
307         sb.append(getName());
308         sb.append(", a2=");
309         sb.append(getA2());
310         sb.append(", a3=");
311         sb.append(getA3());
312         sb.append(", number=");
313         sb.append(getNumber());
314         sb.append(", idd=");
315         sb.append(getIdd());
316         sb.append(", active=");
317         sb.append(getActive());
318         sb.append("}");
319 
320         return sb.toString();
321     }
322 
323     public String toXmlString() {
324         StringBuilder sb = new StringBuilder();
325 
326         sb.append("<model><model-name>");
327         sb.append("com.liferay.portal.model.Country");
328         sb.append("</model-name>");
329 
330         sb.append(
331             "<column><column-name>countryId</column-name><column-value><![CDATA[");
332         sb.append(getCountryId());
333         sb.append("]]></column-value></column>");
334         sb.append(
335             "<column><column-name>name</column-name><column-value><![CDATA[");
336         sb.append(getName());
337         sb.append("]]></column-value></column>");
338         sb.append(
339             "<column><column-name>a2</column-name><column-value><![CDATA[");
340         sb.append(getA2());
341         sb.append("]]></column-value></column>");
342         sb.append(
343             "<column><column-name>a3</column-name><column-value><![CDATA[");
344         sb.append(getA3());
345         sb.append("]]></column-value></column>");
346         sb.append(
347             "<column><column-name>number</column-name><column-value><![CDATA[");
348         sb.append(getNumber());
349         sb.append("]]></column-value></column>");
350         sb.append(
351             "<column><column-name>idd</column-name><column-value><![CDATA[");
352         sb.append(getIdd());
353         sb.append("]]></column-value></column>");
354         sb.append(
355             "<column><column-name>active</column-name><column-value><![CDATA[");
356         sb.append(getActive());
357         sb.append("]]></column-value></column>");
358 
359         sb.append("</model>");
360 
361         return sb.toString();
362     }
363 
364     private long _countryId;
365     private String _name;
366     private String _originalName;
367     private String _a2;
368     private String _originalA2;
369     private String _a3;
370     private String _originalA3;
371     private String _number;
372     private String _idd;
373     private boolean _active;
374 }