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