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