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