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