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.Resource;
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="ResourceModelImpl.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>Resource</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.Resource
052: * @see com.liferay.portal.service.model.ResourceModel
053: * @see com.liferay.portal.service.model.impl.ResourceImpl
054: *
055: */
056: public class ResourceModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "Resource_";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "resourceId", new Integer(Types.BIGINT) },
060:
061: { "codeId", new Integer(Types.BIGINT) },
062:
063: { "primKey", new Integer(Types.VARCHAR) } };
064: public static final String TABLE_SQL_CREATE = "create table Resource_ (resourceId LONG not null primary key,codeId LONG,primKey VARCHAR(300) null)";
065: public static final String TABLE_SQL_DROP = "drop table Resource_";
066: public static final boolean CACHE_ENABLED = GetterUtil
067: .getBoolean(
068: PropsUtil
069: .get("value.object.finder.cache.enabled.com.liferay.portal.model.Resource"),
070: true);
071: public static final long LOCK_EXPIRATION_TIME = GetterUtil
072: .getLong(PropsUtil
073: .get("lock.expiration.time.com.liferay.portal.model.Resource"));
074:
075: public ResourceModelImpl() {
076: }
077:
078: public long getPrimaryKey() {
079: return _resourceId;
080: }
081:
082: public void setPrimaryKey(long pk) {
083: setResourceId(pk);
084: }
085:
086: public Serializable getPrimaryKeyObj() {
087: return new Long(_resourceId);
088: }
089:
090: public long getResourceId() {
091: return _resourceId;
092: }
093:
094: public void setResourceId(long resourceId) {
095: if (resourceId != _resourceId) {
096: _resourceId = resourceId;
097: }
098: }
099:
100: public long getCodeId() {
101: return _codeId;
102: }
103:
104: public void setCodeId(long codeId) {
105: if (codeId != _codeId) {
106: _codeId = codeId;
107: }
108: }
109:
110: public String getPrimKey() {
111: return GetterUtil.getString(_primKey);
112: }
113:
114: public void setPrimKey(String primKey) {
115: if (((primKey == null) && (_primKey != null))
116: || ((primKey != null) && (_primKey == null))
117: || ((primKey != null) && (_primKey != null) && !primKey
118: .equals(_primKey))) {
119: _primKey = primKey;
120: }
121: }
122:
123: public Resource toEscapedModel() {
124: if (isEscapedModel()) {
125: return (Resource) this ;
126: } else {
127: Resource model = new ResourceImpl();
128:
129: model.setEscapedModel(true);
130:
131: model.setResourceId(getResourceId());
132: model.setCodeId(getCodeId());
133: model.setPrimKey(Html.escape(getPrimKey()));
134:
135: model = (Resource) Proxy.newProxyInstance(Resource.class
136: .getClassLoader(), new Class[] { Resource.class },
137: new ReadOnlyBeanHandler(model));
138:
139: return model;
140: }
141: }
142:
143: public Object clone() {
144: ResourceImpl clone = new ResourceImpl();
145:
146: clone.setResourceId(getResourceId());
147: clone.setCodeId(getCodeId());
148: clone.setPrimKey(getPrimKey());
149:
150: return clone;
151: }
152:
153: public int compareTo(Object obj) {
154: if (obj == null) {
155: return -1;
156: }
157:
158: ResourceImpl resource = (ResourceImpl) obj;
159:
160: long pk = resource.getPrimaryKey();
161:
162: if (getPrimaryKey() < pk) {
163: return -1;
164: } else if (getPrimaryKey() > pk) {
165: return 1;
166: } else {
167: return 0;
168: }
169: }
170:
171: public boolean equals(Object obj) {
172: if (obj == null) {
173: return false;
174: }
175:
176: ResourceImpl resource = null;
177:
178: try {
179: resource = (ResourceImpl) obj;
180: } catch (ClassCastException cce) {
181: return false;
182: }
183:
184: long pk = resource.getPrimaryKey();
185:
186: if (getPrimaryKey() == pk) {
187: return true;
188: } else {
189: return false;
190: }
191: }
192:
193: public int hashCode() {
194: return (int) getPrimaryKey();
195: }
196:
197: private long _resourceId;
198: private long _codeId;
199: private String _primKey;
200: }
|