1
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.kernel.util.HtmlUtil;
28 import com.liferay.portal.kernel.util.StringPool;
29 import com.liferay.portal.model.ClassName;
30 import com.liferay.portal.model.ClassNameSoap;
31 import com.liferay.portal.util.PortalUtil;
32
33 import com.liferay.portlet.expando.model.ExpandoBridge;
34 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
35
36 import java.io.Serializable;
37
38 import java.lang.reflect.Proxy;
39
40 import java.sql.Types;
41
42 import java.util.ArrayList;
43 import java.util.List;
44
45
65 public class ClassNameModelImpl extends BaseModelImpl {
66 public static final String TABLE_NAME = "ClassName_";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "classNameId", new Integer(Types.BIGINT) },
69
70
71 { "value", new Integer(Types.VARCHAR) }
72 };
73 public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
74 public static final String TABLE_SQL_DROP = "drop table ClassName_";
75 public static final String DATA_SOURCE = "liferayDataSource";
76 public static final String SESSION_FACTORY = "liferaySessionFactory";
77 public static final String TX_MANAGER = "liferayTransactionManager";
78 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79 "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
80 true);
81
82 public static ClassName toModel(ClassNameSoap soapModel) {
83 ClassName model = new ClassNameImpl();
84
85 model.setClassNameId(soapModel.getClassNameId());
86 model.setValue(soapModel.getValue());
87
88 return model;
89 }
90
91 public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
92 List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
93
94 for (ClassNameSoap soapModel : soapModels) {
95 models.add(toModel(soapModel));
96 }
97
98 return models;
99 }
100
101 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102 "lock.expiration.time.com.liferay.portal.model.ClassName"));
103
104 public ClassNameModelImpl() {
105 }
106
107 public long getPrimaryKey() {
108 return _classNameId;
109 }
110
111 public void setPrimaryKey(long pk) {
112 setClassNameId(pk);
113 }
114
115 public Serializable getPrimaryKeyObj() {
116 return new Long(_classNameId);
117 }
118
119 public String getClassName() {
120 if (getClassNameId() <= 0) {
121 return StringPool.BLANK;
122 }
123
124 return PortalUtil.getClassName(getClassNameId());
125 }
126
127 public long getClassNameId() {
128 return _classNameId;
129 }
130
131 public void setClassNameId(long classNameId) {
132 if (classNameId != _classNameId) {
133 _classNameId = classNameId;
134 }
135 }
136
137 public String getValue() {
138 return GetterUtil.getString(_value);
139 }
140
141 public void setValue(String value) {
142 if (((value == null) && (_value != null)) ||
143 ((value != null) && (_value == null)) ||
144 ((value != null) && (_value != null) && !value.equals(_value))) {
145 _value = value;
146 }
147 }
148
149 public ClassName toEscapedModel() {
150 if (isEscapedModel()) {
151 return (ClassName)this;
152 }
153 else {
154 ClassName model = new ClassNameImpl();
155
156 model.setNew(isNew());
157 model.setEscapedModel(true);
158
159 model.setClassNameId(getClassNameId());
160 model.setValue(HtmlUtil.escape(getValue()));
161
162 model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
163 new Class[] { ClassName.class },
164 new ReadOnlyBeanHandler(model));
165
166 return model;
167 }
168 }
169
170 public ExpandoBridge getExpandoBridge() {
171 if (_expandoBridge == null) {
172 _expandoBridge = new ExpandoBridgeImpl(ClassName.class.getName(),
173 getPrimaryKey());
174 }
175
176 return _expandoBridge;
177 }
178
179 public Object clone() {
180 ClassNameImpl clone = new ClassNameImpl();
181
182 clone.setClassNameId(getClassNameId());
183 clone.setValue(getValue());
184
185 return clone;
186 }
187
188 public int compareTo(Object obj) {
189 if (obj == null) {
190 return -1;
191 }
192
193 ClassNameImpl className = (ClassNameImpl)obj;
194
195 long pk = className.getPrimaryKey();
196
197 if (getPrimaryKey() < pk) {
198 return -1;
199 }
200 else if (getPrimaryKey() > pk) {
201 return 1;
202 }
203 else {
204 return 0;
205 }
206 }
207
208 public boolean equals(Object obj) {
209 if (obj == null) {
210 return false;
211 }
212
213 ClassNameImpl className = null;
214
215 try {
216 className = (ClassNameImpl)obj;
217 }
218 catch (ClassCastException cce) {
219 return false;
220 }
221
222 long pk = className.getPrimaryKey();
223
224 if (getPrimaryKey() == pk) {
225 return true;
226 }
227 else {
228 return false;
229 }
230 }
231
232 public int hashCode() {
233 return (int)getPrimaryKey();
234 }
235
236 private long _classNameId;
237 private String _value;
238 private transient ExpandoBridge _expandoBridge;
239 }