1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.model.ClassName;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="ClassNameModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>ClassName</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.ClassName
54   * @see com.liferay.portal.service.model.ClassNameModel
55   * @see com.liferay.portal.service.model.impl.ClassNameImpl
56   *
57   */
58  public class ClassNameModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "ClassName_";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "classNameId", new Integer(Types.BIGINT) },
62              
63  
64              { "value", new Integer(Types.VARCHAR) }
65          };
66      public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
67      public static final String TABLE_SQL_DROP = "drop table ClassName_";
68      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
69                  "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
70              true);
71      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
72                  "lock.expiration.time.com.liferay.portal.model.ClassName"));
73  
74      public ClassNameModelImpl() {
75      }
76  
77      public long getPrimaryKey() {
78          return _classNameId;
79      }
80  
81      public void setPrimaryKey(long pk) {
82          setClassNameId(pk);
83      }
84  
85      public Serializable getPrimaryKeyObj() {
86          return new Long(_classNameId);
87      }
88  
89      public long getClassNameId() {
90          return _classNameId;
91      }
92  
93      public void setClassNameId(long classNameId) {
94          if (classNameId != _classNameId) {
95              _classNameId = classNameId;
96          }
97      }
98  
99      public String getValue() {
100         return GetterUtil.getString(_value);
101     }
102 
103     public void setValue(String value) {
104         if (((value == null) && (_value != null)) ||
105                 ((value != null) && (_value == null)) ||
106                 ((value != null) && (_value != null) && !value.equals(_value))) {
107             _value = value;
108         }
109     }
110 
111     public ClassName toEscapedModel() {
112         if (isEscapedModel()) {
113             return (ClassName)this;
114         }
115         else {
116             ClassName model = new ClassNameImpl();
117 
118             model.setEscapedModel(true);
119 
120             model.setClassNameId(getClassNameId());
121             model.setValue(Html.escape(getValue()));
122 
123             model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
124                     new Class[] { ClassName.class },
125                     new ReadOnlyBeanHandler(model));
126 
127             return model;
128         }
129     }
130 
131     public Object clone() {
132         ClassNameImpl clone = new ClassNameImpl();
133 
134         clone.setClassNameId(getClassNameId());
135         clone.setValue(getValue());
136 
137         return clone;
138     }
139 
140     public int compareTo(Object obj) {
141         if (obj == null) {
142             return -1;
143         }
144 
145         ClassNameImpl className = (ClassNameImpl)obj;
146 
147         long pk = className.getPrimaryKey();
148 
149         if (getPrimaryKey() < pk) {
150             return -1;
151         }
152         else if (getPrimaryKey() > pk) {
153             return 1;
154         }
155         else {
156             return 0;
157         }
158     }
159 
160     public boolean equals(Object obj) {
161         if (obj == null) {
162             return false;
163         }
164 
165         ClassNameImpl className = null;
166 
167         try {
168             className = (ClassNameImpl)obj;
169         }
170         catch (ClassCastException cce) {
171             return false;
172         }
173 
174         long pk = className.getPrimaryKey();
175 
176         if (getPrimaryKey() == pk) {
177             return true;
178         }
179         else {
180             return false;
181         }
182     }
183 
184     public int hashCode() {
185         return (int)getPrimaryKey();
186     }
187 
188     private long _classNameId;
189     private String _value;
190 }