1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18 import com.liferay.portal.kernel.util.GetterUtil;
19 import com.liferay.portal.kernel.util.StringBundler;
20 import com.liferay.portal.kernel.util.StringPool;
21 import com.liferay.portal.model.ClassName;
22 import com.liferay.portal.model.ClassNameSoap;
23 import com.liferay.portal.service.ServiceContext;
24 import com.liferay.portal.util.PortalUtil;
25
26 import com.liferay.portlet.expando.model.ExpandoBridge;
27 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
28
29 import java.io.Serializable;
30
31 import java.lang.reflect.Proxy;
32
33 import java.sql.Types;
34
35 import java.util.ArrayList;
36 import java.util.List;
37
38
57 public class ClassNameModelImpl extends BaseModelImpl<ClassName> {
58 public static final String TABLE_NAME = "ClassName_";
59 public static final Object[][] TABLE_COLUMNS = {
60 { "classNameId", new Integer(Types.BIGINT) },
61 { "value", new Integer(Types.VARCHAR) }
62 };
63 public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
64 public static final String TABLE_SQL_DROP = "drop table ClassName_";
65 public static final String DATA_SOURCE = "liferayDataSource";
66 public static final String SESSION_FACTORY = "liferaySessionFactory";
67 public static final String TX_MANAGER = "liferayTransactionManager";
68 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
69 "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
70 true);
71 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72 "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
73 true);
74
75 public static ClassName toModel(ClassNameSoap soapModel) {
76 ClassName model = new ClassNameImpl();
77
78 model.setClassNameId(soapModel.getClassNameId());
79 model.setValue(soapModel.getValue());
80
81 return model;
82 }
83
84 public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
85 List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
86
87 for (ClassNameSoap soapModel : soapModels) {
88 models.add(toModel(soapModel));
89 }
90
91 return models;
92 }
93
94 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
95 "lock.expiration.time.com.liferay.portal.model.ClassName"));
96
97 public ClassNameModelImpl() {
98 }
99
100 public long getPrimaryKey() {
101 return _classNameId;
102 }
103
104 public void setPrimaryKey(long pk) {
105 setClassNameId(pk);
106 }
107
108 public Serializable getPrimaryKeyObj() {
109 return new Long(_classNameId);
110 }
111
112 public String getClassName() {
113 if (getClassNameId() <= 0) {
114 return StringPool.BLANK;
115 }
116
117 return PortalUtil.getClassName(getClassNameId());
118 }
119
120 public long getClassNameId() {
121 return _classNameId;
122 }
123
124 public void setClassNameId(long classNameId) {
125 _classNameId = classNameId;
126 }
127
128 public String getValue() {
129 if (_value == null) {
130 return StringPool.BLANK;
131 }
132 else {
133 return _value;
134 }
135 }
136
137 public void setValue(String value) {
138 _value = value;
139
140 if (_originalValue == null) {
141 _originalValue = value;
142 }
143 }
144
145 public String getOriginalValue() {
146 return GetterUtil.getString(_originalValue);
147 }
148
149 public ClassName toEscapedModel() {
150 if (isEscapedModel()) {
151 return (ClassName)this;
152 }
153 else {
154 return (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
155 new Class[] { ClassName.class }, new AutoEscapeBeanHandler(this));
156 }
157 }
158
159 public ExpandoBridge getExpandoBridge() {
160 if (_expandoBridge == null) {
161 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ClassName.class.getName(),
162 getPrimaryKey());
163 }
164
165 return _expandoBridge;
166 }
167
168 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
169 getExpandoBridge().setAttributes(serviceContext);
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 StringBundler sb = new StringBundler(5);
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 StringBundler sb = new StringBundler(10);
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 private transient ExpandoBridge _expandoBridge;
260 }