1   /**
2    * Copyright (c) 2000-2008 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.model.Country;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="CountryModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Country</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.Country
54   * @see com.liferay.portal.service.model.CountryModel
55   * @see com.liferay.portal.service.model.impl.CountryImpl
56   *
57   */
58  public class CountryModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Country";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "countryId", new Integer(Types.BIGINT) },
62              
63  
64              { "name", new Integer(Types.VARCHAR) },
65              
66  
67              { "a2", new Integer(Types.VARCHAR) },
68              
69  
70              { "a3", new Integer(Types.VARCHAR) },
71              
72  
73              { "number_", new Integer(Types.VARCHAR) },
74              
75  
76              { "idd_", new Integer(Types.VARCHAR) },
77              
78  
79              { "active_", new Integer(Types.BOOLEAN) }
80          };
81      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)";
82      public static final String TABLE_SQL_DROP = "drop table Country";
83      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portal.model.Country"),
85              true);
86      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
87                  "lock.expiration.time.com.liferay.portal.model.Country"));
88  
89      public CountryModelImpl() {
90      }
91  
92      public long getPrimaryKey() {
93          return _countryId;
94      }
95  
96      public void setPrimaryKey(long pk) {
97          setCountryId(pk);
98      }
99  
100     public Serializable getPrimaryKeyObj() {
101         return new Long(_countryId);
102     }
103 
104     public long getCountryId() {
105         return _countryId;
106     }
107 
108     public void setCountryId(long countryId) {
109         if (countryId != _countryId) {
110             _countryId = countryId;
111         }
112     }
113 
114     public String getName() {
115         return GetterUtil.getString(_name);
116     }
117 
118     public void setName(String name) {
119         if (((name == null) && (_name != null)) ||
120                 ((name != null) && (_name == null)) ||
121                 ((name != null) && (_name != null) && !name.equals(_name))) {
122             _name = name;
123         }
124     }
125 
126     public String getA2() {
127         return GetterUtil.getString(_a2);
128     }
129 
130     public void setA2(String a2) {
131         if (((a2 == null) && (_a2 != null)) || ((a2 != null) && (_a2 == null)) ||
132                 ((a2 != null) && (_a2 != null) && !a2.equals(_a2))) {
133             _a2 = a2;
134         }
135     }
136 
137     public String getA3() {
138         return GetterUtil.getString(_a3);
139     }
140 
141     public void setA3(String a3) {
142         if (((a3 == null) && (_a3 != null)) || ((a3 != null) && (_a3 == null)) ||
143                 ((a3 != null) && (_a3 != null) && !a3.equals(_a3))) {
144             _a3 = a3;
145         }
146     }
147 
148     public String getNumber() {
149         return GetterUtil.getString(_number);
150     }
151 
152     public void setNumber(String number) {
153         if (((number == null) && (_number != null)) ||
154                 ((number != null) && (_number == null)) ||
155                 ((number != null) && (_number != null) &&
156                 !number.equals(_number))) {
157             _number = number;
158         }
159     }
160 
161     public String getIdd() {
162         return GetterUtil.getString(_idd);
163     }
164 
165     public void setIdd(String idd) {
166         if (((idd == null) && (_idd != null)) ||
167                 ((idd != null) && (_idd == null)) ||
168                 ((idd != null) && (_idd != null) && !idd.equals(_idd))) {
169             _idd = idd;
170         }
171     }
172 
173     public boolean getActive() {
174         return _active;
175     }
176 
177     public boolean isActive() {
178         return _active;
179     }
180 
181     public void setActive(boolean active) {
182         if (active != _active) {
183             _active = active;
184         }
185     }
186 
187     public Country toEscapedModel() {
188         if (isEscapedModel()) {
189             return (Country)this;
190         }
191         else {
192             Country model = new CountryImpl();
193 
194             model.setEscapedModel(true);
195 
196             model.setCountryId(getCountryId());
197             model.setName(Html.escape(getName()));
198             model.setA2(Html.escape(getA2()));
199             model.setA3(Html.escape(getA3()));
200             model.setNumber(Html.escape(getNumber()));
201             model.setIdd(Html.escape(getIdd()));
202             model.setActive(getActive());
203 
204             model = (Country)Proxy.newProxyInstance(Country.class.getClassLoader(),
205                     new Class[] { Country.class },
206                     new ReadOnlyBeanHandler(model));
207 
208             return model;
209         }
210     }
211 
212     public Object clone() {
213         CountryImpl clone = new CountryImpl();
214 
215         clone.setCountryId(getCountryId());
216         clone.setName(getName());
217         clone.setA2(getA2());
218         clone.setA3(getA3());
219         clone.setNumber(getNumber());
220         clone.setIdd(getIdd());
221         clone.setActive(getActive());
222 
223         return clone;
224     }
225 
226     public int compareTo(Object obj) {
227         if (obj == null) {
228             return -1;
229         }
230 
231         CountryImpl country = (CountryImpl)obj;
232 
233         int value = 0;
234 
235         value = getName().compareTo(country.getName());
236 
237         if (value != 0) {
238             return value;
239         }
240 
241         return 0;
242     }
243 
244     public boolean equals(Object obj) {
245         if (obj == null) {
246             return false;
247         }
248 
249         CountryImpl country = null;
250 
251         try {
252             country = (CountryImpl)obj;
253         }
254         catch (ClassCastException cce) {
255             return false;
256         }
257 
258         long pk = country.getPrimaryKey();
259 
260         if (getPrimaryKey() == pk) {
261             return true;
262         }
263         else {
264             return false;
265         }
266     }
267 
268     public int hashCode() {
269         return (int)getPrimaryKey();
270     }
271 
272     private long _countryId;
273     private String _name;
274     private String _a2;
275     private String _a3;
276     private String _number;
277     private String _idd;
278     private boolean _active;
279 }