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.portlet.polls.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.impl.BaseModelImpl;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.portlet.polls.model.PollsChoice;
029:
030: import com.liferay.util.Html;
031:
032: import java.io.Serializable;
033:
034: import java.lang.reflect.Proxy;
035:
036: import java.sql.Types;
037:
038: /**
039: * <a href="PollsChoiceModelImpl.java.html"><b><i>View Source</i></b></a>
040: *
041: * <p>
042: * ServiceBuilder generated this class. Modifications in this class will be
043: * overwritten the next time is generated.
044: * </p>
045: *
046: * <p>
047: * This class is a model that represents the <code>PollsChoice</code> table
048: * in the database.
049: * </p>
050: *
051: * @author Brian Wing Shun Chan
052: *
053: * @see com.liferay.portlet.polls.service.model.PollsChoice
054: * @see com.liferay.portlet.polls.service.model.PollsChoiceModel
055: * @see com.liferay.portlet.polls.service.model.impl.PollsChoiceImpl
056: *
057: */
058: public class PollsChoiceModelImpl extends BaseModelImpl {
059: public static final String TABLE_NAME = "PollsChoice";
060: public static final Object[][] TABLE_COLUMNS = {
061: { "uuid_", new Integer(Types.VARCHAR) },
062:
063: { "choiceId", new Integer(Types.BIGINT) },
064:
065: { "questionId", new Integer(Types.BIGINT) },
066:
067: { "name", new Integer(Types.VARCHAR) },
068:
069: { "description", new Integer(Types.VARCHAR) } };
070: public static final String TABLE_SQL_CREATE = "create table PollsChoice (uuid_ VARCHAR(75) null,choiceId LONG not null primary key,questionId LONG,name VARCHAR(75) null,description VARCHAR(1000) null)";
071: public static final String TABLE_SQL_DROP = "drop table PollsChoice";
072: public static final boolean CACHE_ENABLED = GetterUtil
073: .getBoolean(
074: PropsUtil
075: .get("value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
076: true);
077: public static final long LOCK_EXPIRATION_TIME = GetterUtil
078: .getLong(PropsUtil
079: .get("lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
080:
081: public PollsChoiceModelImpl() {
082: }
083:
084: public long getPrimaryKey() {
085: return _choiceId;
086: }
087:
088: public void setPrimaryKey(long pk) {
089: setChoiceId(pk);
090: }
091:
092: public Serializable getPrimaryKeyObj() {
093: return new Long(_choiceId);
094: }
095:
096: public String getUuid() {
097: return GetterUtil.getString(_uuid);
098: }
099:
100: public void setUuid(String uuid) {
101: if ((uuid != null) && (uuid != _uuid)) {
102: _uuid = uuid;
103: }
104: }
105:
106: public long getChoiceId() {
107: return _choiceId;
108: }
109:
110: public void setChoiceId(long choiceId) {
111: if (choiceId != _choiceId) {
112: _choiceId = choiceId;
113: }
114: }
115:
116: public long getQuestionId() {
117: return _questionId;
118: }
119:
120: public void setQuestionId(long questionId) {
121: if (questionId != _questionId) {
122: _questionId = questionId;
123: }
124: }
125:
126: public String getName() {
127: return GetterUtil.getString(_name);
128: }
129:
130: public void setName(String name) {
131: if (((name == null) && (_name != null))
132: || ((name != null) && (_name == null))
133: || ((name != null) && (_name != null) && !name
134: .equals(_name))) {
135: _name = name;
136: }
137: }
138:
139: public String getDescription() {
140: return GetterUtil.getString(_description);
141: }
142:
143: public void setDescription(String description) {
144: if (((description == null) && (_description != null))
145: || ((description != null) && (_description == null))
146: || ((description != null) && (_description != null) && !description
147: .equals(_description))) {
148: _description = description;
149: }
150: }
151:
152: public PollsChoice toEscapedModel() {
153: if (isEscapedModel()) {
154: return (PollsChoice) this ;
155: } else {
156: PollsChoice model = new PollsChoiceImpl();
157:
158: model.setEscapedModel(true);
159:
160: model.setUuid(Html.escape(getUuid()));
161: model.setChoiceId(getChoiceId());
162: model.setQuestionId(getQuestionId());
163: model.setName(Html.escape(getName()));
164: model.setDescription(Html.escape(getDescription()));
165:
166: model = (PollsChoice) Proxy.newProxyInstance(
167: PollsChoice.class.getClassLoader(),
168: new Class[] { PollsChoice.class },
169: new ReadOnlyBeanHandler(model));
170:
171: return model;
172: }
173: }
174:
175: public Object clone() {
176: PollsChoiceImpl clone = new PollsChoiceImpl();
177:
178: clone.setUuid(getUuid());
179: clone.setChoiceId(getChoiceId());
180: clone.setQuestionId(getQuestionId());
181: clone.setName(getName());
182: clone.setDescription(getDescription());
183:
184: return clone;
185: }
186:
187: public int compareTo(Object obj) {
188: if (obj == null) {
189: return -1;
190: }
191:
192: PollsChoiceImpl pollsChoice = (PollsChoiceImpl) obj;
193:
194: int value = 0;
195:
196: if (getQuestionId() < pollsChoice.getQuestionId()) {
197: value = -1;
198: } else if (getQuestionId() > pollsChoice.getQuestionId()) {
199: value = 1;
200: } else {
201: value = 0;
202: }
203:
204: if (value != 0) {
205: return value;
206: }
207:
208: value = getName().compareTo(pollsChoice.getName());
209:
210: if (value != 0) {
211: return value;
212: }
213:
214: return 0;
215: }
216:
217: public boolean equals(Object obj) {
218: if (obj == null) {
219: return false;
220: }
221:
222: PollsChoiceImpl pollsChoice = null;
223:
224: try {
225: pollsChoice = (PollsChoiceImpl) obj;
226: } catch (ClassCastException cce) {
227: return false;
228: }
229:
230: long pk = pollsChoice.getPrimaryKey();
231:
232: if (getPrimaryKey() == pk) {
233: return true;
234: } else {
235: return false;
236: }
237: }
238:
239: public int hashCode() {
240: return (int) getPrimaryKey();
241: }
242:
243: private String _uuid;
244: private long _choiceId;
245: private long _questionId;
246: private String _name;
247: private String _description;
248: }
|