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