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