001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.Region;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.util.Html;
029:
030: import java.io.Serializable;
031:
032: import java.lang.reflect.Proxy;
033:
034: import java.sql.Types;
035:
036: /**
037: * <a href="RegionModelImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * <p>
040: * ServiceBuilder generated this class. Modifications in this class will be
041: * overwritten the next time is generated.
042: * </p>
043: *
044: * <p>
045: * This class is a model that represents the <code>Region</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.Region
052: * @see com.liferay.portal.service.model.RegionModel
053: * @see com.liferay.portal.service.model.impl.RegionImpl
054: *
055: */
056: public class RegionModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "Region";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "regionId", new Integer(Types.BIGINT) },
060:
061: { "countryId", new Integer(Types.BIGINT) },
062:
063: { "regionCode", new Integer(Types.VARCHAR) },
064:
065: { "name", new Integer(Types.VARCHAR) },
066:
067: { "active_", new Integer(Types.BOOLEAN) } };
068: 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)";
069: public static final String TABLE_SQL_DROP = "drop table Region";
070: public static final boolean CACHE_ENABLED = GetterUtil
071: .getBoolean(
072: PropsUtil
073: .get("value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
074: true);
075: public static final long LOCK_EXPIRATION_TIME = GetterUtil
076: .getLong(PropsUtil
077: .get("lock.expiration.time.com.liferay.portal.model.Region"));
078:
079: public RegionModelImpl() {
080: }
081:
082: public long getPrimaryKey() {
083: return _regionId;
084: }
085:
086: public void setPrimaryKey(long pk) {
087: setRegionId(pk);
088: }
089:
090: public Serializable getPrimaryKeyObj() {
091: return new Long(_regionId);
092: }
093:
094: public long getRegionId() {
095: return _regionId;
096: }
097:
098: public void setRegionId(long regionId) {
099: if (regionId != _regionId) {
100: _regionId = regionId;
101: }
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 getRegionCode() {
115: return GetterUtil.getString(_regionCode);
116: }
117:
118: public void setRegionCode(String regionCode) {
119: if (((regionCode == null) && (_regionCode != null))
120: || ((regionCode != null) && (_regionCode == null))
121: || ((regionCode != null) && (_regionCode != null) && !regionCode
122: .equals(_regionCode))) {
123: _regionCode = regionCode;
124: }
125: }
126:
127: public String getName() {
128: return GetterUtil.getString(_name);
129: }
130:
131: public void setName(String name) {
132: if (((name == null) && (_name != null))
133: || ((name != null) && (_name == null))
134: || ((name != null) && (_name != null) && !name
135: .equals(_name))) {
136: _name = name;
137: }
138: }
139:
140: public boolean getActive() {
141: return _active;
142: }
143:
144: public boolean isActive() {
145: return _active;
146: }
147:
148: public void setActive(boolean active) {
149: if (active != _active) {
150: _active = active;
151: }
152: }
153:
154: public Region toEscapedModel() {
155: if (isEscapedModel()) {
156: return (Region) this ;
157: } else {
158: Region model = new RegionImpl();
159:
160: model.setEscapedModel(true);
161:
162: model.setRegionId(getRegionId());
163: model.setCountryId(getCountryId());
164: model.setRegionCode(Html.escape(getRegionCode()));
165: model.setName(Html.escape(getName()));
166: model.setActive(getActive());
167:
168: model = (Region) Proxy.newProxyInstance(Region.class
169: .getClassLoader(), new Class[] { Region.class },
170: new ReadOnlyBeanHandler(model));
171:
172: return model;
173: }
174: }
175:
176: public Object clone() {
177: RegionImpl clone = new RegionImpl();
178:
179: clone.setRegionId(getRegionId());
180: clone.setCountryId(getCountryId());
181: clone.setRegionCode(getRegionCode());
182: clone.setName(getName());
183: clone.setActive(getActive());
184:
185: return clone;
186: }
187:
188: public int compareTo(Object obj) {
189: if (obj == null) {
190: return -1;
191: }
192:
193: RegionImpl region = (RegionImpl) obj;
194:
195: int value = 0;
196:
197: value = getName().compareTo(region.getName());
198:
199: if (value != 0) {
200: return value;
201: }
202:
203: return 0;
204: }
205:
206: public boolean equals(Object obj) {
207: if (obj == null) {
208: return false;
209: }
210:
211: RegionImpl region = null;
212:
213: try {
214: region = (RegionImpl) obj;
215: } catch (ClassCastException cce) {
216: return false;
217: }
218:
219: long pk = region.getPrimaryKey();
220:
221: if (getPrimaryKey() == pk) {
222: return true;
223: } else {
224: return false;
225: }
226: }
227:
228: public int hashCode() {
229: return (int) getPrimaryKey();
230: }
231:
232: private long _regionId;
233: private long _countryId;
234: private String _regionCode;
235: private String _name;
236: private boolean _active;
237: }
|