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