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 com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 ExpandoBridge getExpandoBridge() {
248         if (_expandoBridge == null) {
249             _expandoBridge = new ExpandoBridgeImpl(Country.class.getName(),
250                     getPrimaryKey());
251         }
252 
253         return _expandoBridge;
254     }
255 
256     public Object clone() {
257         CountryImpl clone = new CountryImpl();
258 
259         clone.setCountryId(getCountryId());
260         clone.setName(getName());
261         clone.setA2(getA2());
262         clone.setA3(getA3());
263         clone.setNumber(getNumber());
264         clone.setIdd(getIdd());
265         clone.setActive(getActive());
266 
267         return clone;
268     }
269 
270     public int compareTo(Country country) {
271         int value = 0;
272 
273         value = getName().compareTo(country.getName());
274 
275         if (value != 0) {
276             return value;
277         }
278 
279         return 0;
280     }
281 
282     public boolean equals(Object obj) {
283         if (obj == null) {
284             return false;
285         }
286 
287         Country country = null;
288 
289         try {
290             country = (Country)obj;
291         }
292         catch (ClassCastException cce) {
293             return false;
294         }
295 
296         long pk = country.getPrimaryKey();
297 
298         if (getPrimaryKey() == pk) {
299             return true;
300         }
301         else {
302             return false;
303         }
304     }
305 
306     public int hashCode() {
307         return (int)getPrimaryKey();
308     }
309 
310     public String toString() {
311         StringBuilder sb = new StringBuilder();
312 
313         sb.append("{countryId=");
314         sb.append(getCountryId());
315         sb.append(", name=");
316         sb.append(getName());
317         sb.append(", a2=");
318         sb.append(getA2());
319         sb.append(", a3=");
320         sb.append(getA3());
321         sb.append(", number=");
322         sb.append(getNumber());
323         sb.append(", idd=");
324         sb.append(getIdd());
325         sb.append(", active=");
326         sb.append(getActive());
327         sb.append("}");
328 
329         return sb.toString();
330     }
331 
332     public String toXmlString() {
333         StringBuilder sb = new StringBuilder();
334 
335         sb.append("<model><model-name>");
336         sb.append("com.liferay.portal.model.Country");
337         sb.append("</model-name>");
338 
339         sb.append(
340             "<column><column-name>countryId</column-name><column-value><![CDATA[");
341         sb.append(getCountryId());
342         sb.append("]]></column-value></column>");
343         sb.append(
344             "<column><column-name>name</column-name><column-value><![CDATA[");
345         sb.append(getName());
346         sb.append("]]></column-value></column>");
347         sb.append(
348             "<column><column-name>a2</column-name><column-value><![CDATA[");
349         sb.append(getA2());
350         sb.append("]]></column-value></column>");
351         sb.append(
352             "<column><column-name>a3</column-name><column-value><![CDATA[");
353         sb.append(getA3());
354         sb.append("]]></column-value></column>");
355         sb.append(
356             "<column><column-name>number</column-name><column-value><![CDATA[");
357         sb.append(getNumber());
358         sb.append("]]></column-value></column>");
359         sb.append(
360             "<column><column-name>idd</column-name><column-value><![CDATA[");
361         sb.append(getIdd());
362         sb.append("]]></column-value></column>");
363         sb.append(
364             "<column><column-name>active</column-name><column-value><![CDATA[");
365         sb.append(getActive());
366         sb.append("]]></column-value></column>");
367 
368         sb.append("</model>");
369 
370         return sb.toString();
371     }
372 
373     private long _countryId;
374     private String _name;
375     private String _originalName;
376     private String _a2;
377     private String _originalA2;
378     private String _a3;
379     private String _originalA3;
380     private String _number;
381     private String _idd;
382     private boolean _active;
383     private transient ExpandoBridge _expandoBridge;
384 }