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.Region;
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="RegionModelImpl.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>Region</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.Region
54   * @see com.liferay.portal.service.model.RegionModel
55   * @see com.liferay.portal.service.model.impl.RegionImpl
56   *
57   */
58  public class RegionModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Region";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "regionId", new Integer(Types.BIGINT) },
62              
63  
64              { "countryId", new Integer(Types.BIGINT) },
65              
66  
67              { "regionCode", new Integer(Types.VARCHAR) },
68              
69  
70              { "name", new Integer(Types.VARCHAR) },
71              
72  
73              { "active_", new Integer(Types.BOOLEAN) }
74          };
75      public static final String TABLE_SQL_CREATE = "create table Region (regionId LONG not null primary key,countryId LONG,regionCode VARCHAR(75) null,name VARCHAR(75) null,active_ BOOLEAN)";
76      public static final String TABLE_SQL_DROP = "drop table Region";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
79              true);
80      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
81                  "lock.expiration.time.com.liferay.portal.model.Region"));
82  
83      public RegionModelImpl() {
84      }
85  
86      public long getPrimaryKey() {
87          return _regionId;
88      }
89  
90      public void setPrimaryKey(long pk) {
91          setRegionId(pk);
92      }
93  
94      public Serializable getPrimaryKeyObj() {
95          return new Long(_regionId);
96      }
97  
98      public long getRegionId() {
99          return _regionId;
100     }
101 
102     public void setRegionId(long regionId) {
103         if (regionId != _regionId) {
104             _regionId = regionId;
105         }
106     }
107 
108     public long getCountryId() {
109         return _countryId;
110     }
111 
112     public void setCountryId(long countryId) {
113         if (countryId != _countryId) {
114             _countryId = countryId;
115         }
116     }
117 
118     public String getRegionCode() {
119         return GetterUtil.getString(_regionCode);
120     }
121 
122     public void setRegionCode(String regionCode) {
123         if (((regionCode == null) && (_regionCode != null)) ||
124                 ((regionCode != null) && (_regionCode == null)) ||
125                 ((regionCode != null) && (_regionCode != null) &&
126                 !regionCode.equals(_regionCode))) {
127             _regionCode = regionCode;
128         }
129     }
130 
131     public String getName() {
132         return GetterUtil.getString(_name);
133     }
134 
135     public void setName(String name) {
136         if (((name == null) && (_name != null)) ||
137                 ((name != null) && (_name == null)) ||
138                 ((name != null) && (_name != null) && !name.equals(_name))) {
139             _name = name;
140         }
141     }
142 
143     public boolean getActive() {
144         return _active;
145     }
146 
147     public boolean isActive() {
148         return _active;
149     }
150 
151     public void setActive(boolean active) {
152         if (active != _active) {
153             _active = active;
154         }
155     }
156 
157     public Region toEscapedModel() {
158         if (isEscapedModel()) {
159             return (Region)this;
160         }
161         else {
162             Region model = new RegionImpl();
163 
164             model.setEscapedModel(true);
165 
166             model.setRegionId(getRegionId());
167             model.setCountryId(getCountryId());
168             model.setRegionCode(Html.escape(getRegionCode()));
169             model.setName(Html.escape(getName()));
170             model.setActive(getActive());
171 
172             model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
173                     new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
174 
175             return model;
176         }
177     }
178 
179     public Object clone() {
180         RegionImpl clone = new RegionImpl();
181 
182         clone.setRegionId(getRegionId());
183         clone.setCountryId(getCountryId());
184         clone.setRegionCode(getRegionCode());
185         clone.setName(getName());
186         clone.setActive(getActive());
187 
188         return clone;
189     }
190 
191     public int compareTo(Object obj) {
192         if (obj == null) {
193             return -1;
194         }
195 
196         RegionImpl region = (RegionImpl)obj;
197 
198         int value = 0;
199 
200         value = getName().compareTo(region.getName());
201 
202         if (value != 0) {
203             return value;
204         }
205 
206         return 0;
207     }
208 
209     public boolean equals(Object obj) {
210         if (obj == null) {
211             return false;
212         }
213 
214         RegionImpl region = null;
215 
216         try {
217             region = (RegionImpl)obj;
218         }
219         catch (ClassCastException cce) {
220             return false;
221         }
222 
223         long pk = region.getPrimaryKey();
224 
225         if (getPrimaryKey() == pk) {
226             return true;
227         }
228         else {
229             return false;
230         }
231     }
232 
233     public int hashCode() {
234         return (int)getPrimaryKey();
235     }
236 
237     private long _regionId;
238     private long _countryId;
239     private String _regionCode;
240     private String _name;
241     private boolean _active;
242 }