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