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.model.ListType;
29  import com.liferay.portal.model.ListTypeSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="ListTypeModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the ListType table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       ListTypeImpl
55   * @see       com.liferay.portal.model.ListType
56   * @see       com.liferay.portal.model.ListTypeModel
57   * @generated
58   */
59  public class ListTypeModelImpl extends BaseModelImpl<ListType> {
60      public static final String TABLE_NAME = "ListType";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "listTypeId", new Integer(Types.INTEGER) },
63              { "name", new Integer(Types.VARCHAR) },
64              { "type_", new Integer(Types.VARCHAR) }
65          };
66      public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
67      public static final String TABLE_SQL_DROP = "drop table ListType";
68      public static final String DATA_SOURCE = "liferayDataSource";
69      public static final String SESSION_FACTORY = "liferaySessionFactory";
70      public static final String TX_MANAGER = "liferayTransactionManager";
71      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72                  "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
73              true);
74      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
76              true);
77  
78      public static ListType toModel(ListTypeSoap soapModel) {
79          ListType model = new ListTypeImpl();
80  
81          model.setListTypeId(soapModel.getListTypeId());
82          model.setName(soapModel.getName());
83          model.setType(soapModel.getType());
84  
85          return model;
86      }
87  
88      public static List<ListType> toModels(ListTypeSoap[] soapModels) {
89          List<ListType> models = new ArrayList<ListType>(soapModels.length);
90  
91          for (ListTypeSoap soapModel : soapModels) {
92              models.add(toModel(soapModel));
93          }
94  
95          return models;
96      }
97  
98      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
99                  "lock.expiration.time.com.liferay.portal.model.ListType"));
100 
101     public ListTypeModelImpl() {
102     }
103 
104     public int getPrimaryKey() {
105         return _listTypeId;
106     }
107 
108     public void setPrimaryKey(int pk) {
109         setListTypeId(pk);
110     }
111 
112     public Serializable getPrimaryKeyObj() {
113         return new Integer(_listTypeId);
114     }
115 
116     public int getListTypeId() {
117         return _listTypeId;
118     }
119 
120     public void setListTypeId(int listTypeId) {
121         _listTypeId = listTypeId;
122     }
123 
124     public String getName() {
125         return GetterUtil.getString(_name);
126     }
127 
128     public void setName(String name) {
129         _name = name;
130     }
131 
132     public String getType() {
133         return GetterUtil.getString(_type);
134     }
135 
136     public void setType(String type) {
137         _type = type;
138     }
139 
140     public ListType toEscapedModel() {
141         if (isEscapedModel()) {
142             return (ListType)this;
143         }
144         else {
145             ListType model = new ListTypeImpl();
146 
147             model.setNew(isNew());
148             model.setEscapedModel(true);
149 
150             model.setListTypeId(getListTypeId());
151             model.setName(HtmlUtil.escape(getName()));
152             model.setType(HtmlUtil.escape(getType()));
153 
154             model = (ListType)Proxy.newProxyInstance(ListType.class.getClassLoader(),
155                     new Class[] { ListType.class },
156                     new ReadOnlyBeanHandler(model));
157 
158             return model;
159         }
160     }
161 
162     public Object clone() {
163         ListTypeImpl clone = new ListTypeImpl();
164 
165         clone.setListTypeId(getListTypeId());
166         clone.setName(getName());
167         clone.setType(getType());
168 
169         return clone;
170     }
171 
172     public int compareTo(ListType listType) {
173         int value = 0;
174 
175         value = getName().toLowerCase()
176                     .compareTo(listType.getName().toLowerCase());
177 
178         if (value != 0) {
179             return value;
180         }
181 
182         return 0;
183     }
184 
185     public boolean equals(Object obj) {
186         if (obj == null) {
187             return false;
188         }
189 
190         ListType listType = null;
191 
192         try {
193             listType = (ListType)obj;
194         }
195         catch (ClassCastException cce) {
196             return false;
197         }
198 
199         int pk = listType.getPrimaryKey();
200 
201         if (getPrimaryKey() == pk) {
202             return true;
203         }
204         else {
205             return false;
206         }
207     }
208 
209     public int hashCode() {
210         return getPrimaryKey();
211     }
212 
213     public String toString() {
214         StringBuilder sb = new StringBuilder();
215 
216         sb.append("{listTypeId=");
217         sb.append(getListTypeId());
218         sb.append(", name=");
219         sb.append(getName());
220         sb.append(", type=");
221         sb.append(getType());
222         sb.append("}");
223 
224         return sb.toString();
225     }
226 
227     public String toXmlString() {
228         StringBuilder sb = new StringBuilder();
229 
230         sb.append("<model><model-name>");
231         sb.append("com.liferay.portal.model.ListType");
232         sb.append("</model-name>");
233 
234         sb.append(
235             "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
236         sb.append(getListTypeId());
237         sb.append("]]></column-value></column>");
238         sb.append(
239             "<column><column-name>name</column-name><column-value><![CDATA[");
240         sb.append(getName());
241         sb.append("]]></column-value></column>");
242         sb.append(
243             "<column><column-name>type</column-name><column-value><![CDATA[");
244         sb.append(getType());
245         sb.append("]]></column-value></column>");
246 
247         sb.append("</model>");
248 
249         return sb.toString();
250     }
251 
252     private int _listTypeId;
253     private String _name;
254     private String _type;
255 }