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