1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.StringBundler;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.model.ClassName;
31  import com.liferay.portal.model.ClassNameSoap;
32  import com.liferay.portal.service.ServiceContext;
33  import com.liferay.portal.util.PortalUtil;
34  
35  import com.liferay.portlet.expando.model.ExpandoBridge;
36  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
37  
38  import java.io.Serializable;
39  
40  import java.lang.reflect.Proxy;
41  
42  import java.sql.Types;
43  
44  import java.util.ArrayList;
45  import java.util.List;
46  
47  /**
48   * <a href="ClassNameModelImpl.java.html"><b><i>View Source</i></b></a>
49   *
50   * <p>
51   * ServiceBuilder generated this class. Modifications in this class will be
52   * overwritten the next time is generated.
53   * </p>
54   *
55   * <p>
56   * This interface is a model that represents the ClassName_ table in the
57   * database.
58   * </p>
59   *
60   * @author    Brian Wing Shun Chan
61   * @see       ClassNameImpl
62   * @see       com.liferay.portal.model.ClassName
63   * @see       com.liferay.portal.model.ClassNameModel
64   * @generated
65   */
66  public class ClassNameModelImpl extends BaseModelImpl<ClassName> {
67      public static final String TABLE_NAME = "ClassName_";
68      public static final Object[][] TABLE_COLUMNS = {
69              { "classNameId", new Integer(Types.BIGINT) },
70              { "value", new Integer(Types.VARCHAR) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
73      public static final String TABLE_SQL_DROP = "drop table ClassName_";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
82              true);
83  
84      public static ClassName toModel(ClassNameSoap soapModel) {
85          ClassName model = new ClassNameImpl();
86  
87          model.setClassNameId(soapModel.getClassNameId());
88          model.setValue(soapModel.getValue());
89  
90          return model;
91      }
92  
93      public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
94          List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
95  
96          for (ClassNameSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portal.model.ClassName"));
105 
106     public ClassNameModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _classNameId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setClassNameId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_classNameId);
119     }
120 
121     public String getClassName() {
122         if (getClassNameId() <= 0) {
123             return StringPool.BLANK;
124         }
125 
126         return PortalUtil.getClassName(getClassNameId());
127     }
128 
129     public long getClassNameId() {
130         return _classNameId;
131     }
132 
133     public void setClassNameId(long classNameId) {
134         _classNameId = classNameId;
135     }
136 
137     public String getValue() {
138         return GetterUtil.getString(_value);
139     }
140 
141     public void setValue(String value) {
142         _value = value;
143 
144         if (_originalValue == null) {
145             _originalValue = value;
146         }
147     }
148 
149     public String getOriginalValue() {
150         return GetterUtil.getString(_originalValue);
151     }
152 
153     public ClassName toEscapedModel() {
154         if (isEscapedModel()) {
155             return (ClassName)this;
156         }
157         else {
158             ClassName model = new ClassNameImpl();
159 
160             model.setNew(isNew());
161             model.setEscapedModel(true);
162 
163             model.setClassNameId(getClassNameId());
164             model.setValue(HtmlUtil.escape(getValue()));
165 
166             model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
167                     new Class[] { ClassName.class },
168                     new ReadOnlyBeanHandler(model));
169 
170             return model;
171         }
172     }
173 
174     public ExpandoBridge getExpandoBridge() {
175         if (_expandoBridge == null) {
176             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ClassName.class.getName(),
177                     getPrimaryKey());
178         }
179 
180         return _expandoBridge;
181     }
182 
183     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
184         getExpandoBridge().setAttributes(serviceContext);
185     }
186 
187     public Object clone() {
188         ClassNameImpl clone = new ClassNameImpl();
189 
190         clone.setClassNameId(getClassNameId());
191         clone.setValue(getValue());
192 
193         return clone;
194     }
195 
196     public int compareTo(ClassName className) {
197         long pk = className.getPrimaryKey();
198 
199         if (getPrimaryKey() < pk) {
200             return -1;
201         }
202         else if (getPrimaryKey() > pk) {
203             return 1;
204         }
205         else {
206             return 0;
207         }
208     }
209 
210     public boolean equals(Object obj) {
211         if (obj == null) {
212             return false;
213         }
214 
215         ClassName className = null;
216 
217         try {
218             className = (ClassName)obj;
219         }
220         catch (ClassCastException cce) {
221             return false;
222         }
223 
224         long pk = className.getPrimaryKey();
225 
226         if (getPrimaryKey() == pk) {
227             return true;
228         }
229         else {
230             return false;
231         }
232     }
233 
234     public int hashCode() {
235         return (int)getPrimaryKey();
236     }
237 
238     public String toString() {
239         StringBundler sb = new StringBundler(5);
240 
241         sb.append("{classNameId=");
242         sb.append(getClassNameId());
243         sb.append(", value=");
244         sb.append(getValue());
245         sb.append("}");
246 
247         return sb.toString();
248     }
249 
250     public String toXmlString() {
251         StringBundler sb = new StringBundler(10);
252 
253         sb.append("<model><model-name>");
254         sb.append("com.liferay.portal.model.ClassName");
255         sb.append("</model-name>");
256 
257         sb.append(
258             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
259         sb.append(getClassNameId());
260         sb.append("]]></column-value></column>");
261         sb.append(
262             "<column><column-name>value</column-name><column-value><![CDATA[");
263         sb.append(getValue());
264         sb.append("]]></column-value></column>");
265 
266         sb.append("</model>");
267 
268         return sb.toString();
269     }
270 
271     private long _classNameId;
272     private String _value;
273     private String _originalValue;
274     private transient ExpandoBridge _expandoBridge;
275 }