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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.ClassName;
29  import com.liferay.portal.model.ClassNameSoap;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="ClassNameModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>ClassName</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.ClassName
57   * @see com.liferay.portal.service.model.ClassNameModel
58   * @see com.liferay.portal.service.model.impl.ClassNameImpl
59   *
60   */
61  public class ClassNameModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "ClassName_";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "classNameId", new Integer(Types.BIGINT) },
65              
66  
67              { "value", new Integer(Types.VARCHAR) }
68          };
69      public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
70      public static final String TABLE_SQL_DROP = "drop table ClassName_";
71      public static final String DATA_SOURCE = "liferayDataSource";
72      public static final String SESSION_FACTORY = "liferaySessionFactory";
73      public static final String TX_MANAGER = "liferayTransactionManager";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
76              true);
77  
78      public static ClassName toModel(ClassNameSoap soapModel) {
79          ClassName model = new ClassNameImpl();
80  
81          model.setClassNameId(soapModel.getClassNameId());
82          model.setValue(soapModel.getValue());
83  
84          return model;
85      }
86  
87      public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
88          List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
89  
90          for (ClassNameSoap soapModel : soapModels) {
91              models.add(toModel(soapModel));
92          }
93  
94          return models;
95      }
96  
97      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
98                  "lock.expiration.time.com.liferay.portal.model.ClassName"));
99  
100     public ClassNameModelImpl() {
101     }
102 
103     public long getPrimaryKey() {
104         return _classNameId;
105     }
106 
107     public void setPrimaryKey(long pk) {
108         setClassNameId(pk);
109     }
110 
111     public Serializable getPrimaryKeyObj() {
112         return new Long(_classNameId);
113     }
114 
115     public String getClassName() {
116         return PortalUtil.getClassName(getClassNameId());
117     }
118 
119     public long getClassNameId() {
120         return _classNameId;
121     }
122 
123     public void setClassNameId(long classNameId) {
124         if (classNameId != _classNameId) {
125             _classNameId = classNameId;
126         }
127     }
128 
129     public String getValue() {
130         return GetterUtil.getString(_value);
131     }
132 
133     public void setValue(String value) {
134         if (((value == null) && (_value != null)) ||
135                 ((value != null) && (_value == null)) ||
136                 ((value != null) && (_value != null) && !value.equals(_value))) {
137             _value = value;
138         }
139     }
140 
141     public ClassName toEscapedModel() {
142         if (isEscapedModel()) {
143             return (ClassName)this;
144         }
145         else {
146             ClassName model = new ClassNameImpl();
147 
148             model.setEscapedModel(true);
149 
150             model.setClassNameId(getClassNameId());
151             model.setValue(HtmlUtil.escape(getValue()));
152 
153             model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
154                     new Class[] { ClassName.class },
155                     new ReadOnlyBeanHandler(model));
156 
157             return model;
158         }
159     }
160 
161     public Object clone() {
162         ClassNameImpl clone = new ClassNameImpl();
163 
164         clone.setClassNameId(getClassNameId());
165         clone.setValue(getValue());
166 
167         return clone;
168     }
169 
170     public int compareTo(Object obj) {
171         if (obj == null) {
172             return -1;
173         }
174 
175         ClassNameImpl className = (ClassNameImpl)obj;
176 
177         long pk = className.getPrimaryKey();
178 
179         if (getPrimaryKey() < pk) {
180             return -1;
181         }
182         else if (getPrimaryKey() > pk) {
183             return 1;
184         }
185         else {
186             return 0;
187         }
188     }
189 
190     public boolean equals(Object obj) {
191         if (obj == null) {
192             return false;
193         }
194 
195         ClassNameImpl className = null;
196 
197         try {
198             className = (ClassNameImpl)obj;
199         }
200         catch (ClassCastException cce) {
201             return false;
202         }
203 
204         long pk = className.getPrimaryKey();
205 
206         if (getPrimaryKey() == pk) {
207             return true;
208         }
209         else {
210             return false;
211         }
212     }
213 
214     public int hashCode() {
215         return (int)getPrimaryKey();
216     }
217 
218     private long _classNameId;
219     private String _value;
220 }