1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18 import com.liferay.portal.kernel.util.GetterUtil;
19 import com.liferay.portal.kernel.util.HtmlUtil;
20 import com.liferay.portal.kernel.util.StringBundler;
21 import com.liferay.portal.kernel.util.StringPool;
22 import com.liferay.portal.model.ClassName;
23 import com.liferay.portal.model.ClassNameSoap;
24 import com.liferay.portal.service.ServiceContext;
25 import com.liferay.portal.util.PortalUtil;
26
27 import com.liferay.portlet.expando.model.ExpandoBridge;
28 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29
30 import java.io.Serializable;
31
32 import java.lang.reflect.Proxy;
33
34 import java.sql.Types;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39
58 public class ClassNameModelImpl extends BaseModelImpl<ClassName> {
59 public static final String TABLE_NAME = "ClassName_";
60 public static final Object[][] TABLE_COLUMNS = {
61 { "classNameId", new Integer(Types.BIGINT) },
62 { "value", new Integer(Types.VARCHAR) }
63 };
64 public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
65 public static final String TABLE_SQL_DROP = "drop table ClassName_";
66 public static final String DATA_SOURCE = "liferayDataSource";
67 public static final String SESSION_FACTORY = "liferaySessionFactory";
68 public static final String TX_MANAGER = "liferayTransactionManager";
69 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70 "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
71 true);
72 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73 "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
74 true);
75
76 public static ClassName toModel(ClassNameSoap soapModel) {
77 ClassName model = new ClassNameImpl();
78
79 model.setClassNameId(soapModel.getClassNameId());
80 model.setValue(soapModel.getValue());
81
82 return model;
83 }
84
85 public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
86 List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
87
88 for (ClassNameSoap soapModel : soapModels) {
89 models.add(toModel(soapModel));
90 }
91
92 return models;
93 }
94
95 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
96 "lock.expiration.time.com.liferay.portal.model.ClassName"));
97
98 public ClassNameModelImpl() {
99 }
100
101 public long getPrimaryKey() {
102 return _classNameId;
103 }
104
105 public void setPrimaryKey(long pk) {
106 setClassNameId(pk);
107 }
108
109 public Serializable getPrimaryKeyObj() {
110 return new Long(_classNameId);
111 }
112
113 public String getClassName() {
114 if (getClassNameId() <= 0) {
115 return StringPool.BLANK;
116 }
117
118 return PortalUtil.getClassName(getClassNameId());
119 }
120
121 public long getClassNameId() {
122 return _classNameId;
123 }
124
125 public void setClassNameId(long classNameId) {
126 _classNameId = classNameId;
127 }
128
129 public String getValue() {
130 return GetterUtil.getString(_value);
131 }
132
133 public void setValue(String value) {
134 _value = value;
135
136 if (_originalValue == null) {
137 _originalValue = value;
138 }
139 }
140
141 public String getOriginalValue() {
142 return GetterUtil.getString(_originalValue);
143 }
144
145 public ClassName toEscapedModel() {
146 if (isEscapedModel()) {
147 return (ClassName)this;
148 }
149 else {
150 ClassName model = new ClassNameImpl();
151
152 model.setNew(isNew());
153 model.setEscapedModel(true);
154
155 model.setClassNameId(getClassNameId());
156 model.setValue(HtmlUtil.escape(getValue()));
157
158 model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
159 new Class[] { ClassName.class },
160 new ReadOnlyBeanHandler(model));
161
162 return model;
163 }
164 }
165
166 public ExpandoBridge getExpandoBridge() {
167 if (_expandoBridge == null) {
168 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
169 ClassName.class.getName(), getPrimaryKey());
170 }
171
172 return _expandoBridge;
173 }
174
175 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
176 getExpandoBridge().setAttributes(serviceContext);
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(ClassName className) {
189 long pk = className.getPrimaryKey();
190
191 if (getPrimaryKey() < pk) {
192 return -1;
193 }
194 else if (getPrimaryKey() > pk) {
195 return 1;
196 }
197 else {
198 return 0;
199 }
200 }
201
202 public boolean equals(Object obj) {
203 if (obj == null) {
204 return false;
205 }
206
207 ClassName className = null;
208
209 try {
210 className = (ClassName)obj;
211 }
212 catch (ClassCastException cce) {
213 return false;
214 }
215
216 long pk = className.getPrimaryKey();
217
218 if (getPrimaryKey() == pk) {
219 return true;
220 }
221 else {
222 return false;
223 }
224 }
225
226 public int hashCode() {
227 return (int)getPrimaryKey();
228 }
229
230 public String toString() {
231 StringBundler sb = new StringBundler(5);
232
233 sb.append("{classNameId=");
234 sb.append(getClassNameId());
235 sb.append(", value=");
236 sb.append(getValue());
237 sb.append("}");
238
239 return sb.toString();
240 }
241
242 public String toXmlString() {
243 StringBundler sb = new StringBundler(10);
244
245 sb.append("<model><model-name>");
246 sb.append("com.liferay.portal.model.ClassName");
247 sb.append("</model-name>");
248
249 sb.append(
250 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
251 sb.append(getClassNameId());
252 sb.append("]]></column-value></column>");
253 sb.append(
254 "<column><column-name>value</column-name><column-value><![CDATA[");
255 sb.append(getValue());
256 sb.append("]]></column-value></column>");
257
258 sb.append("</model>");
259
260 return sb.toString();
261 }
262
263 private long _classNameId;
264 private String _value;
265 private String _originalValue;
266 private transient ExpandoBridge _expandoBridge;
267 }