1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  /**
36   * <a href="ListTypeModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>ListType</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.ListType
51   * @see com.liferay.portal.service.model.ListTypeModel
52   * @see com.liferay.portal.service.model.impl.ListTypeImpl
53   *
54   */
55  public class ListTypeModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "ListType";
57      public static Object[][] TABLE_COLUMNS = {
58              { "listTypeId", new Integer(Types.INTEGER) },
59              { "name", new Integer(Types.VARCHAR) },
60              { "type_", new Integer(Types.VARCHAR) }
61          };
62      public static String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
63      public static String TABLE_SQL_DROP = "drop table ListType";
64      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
65                  "xss.allow.com.liferay.portal.model.ListType"), XSS_ALLOW);
66      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
67                  "xss.allow.com.liferay.portal.model.ListType.name"),
68              XSS_ALLOW_BY_MODEL);
69      public static boolean XSS_ALLOW_TYPE = GetterUtil.getBoolean(PropsUtil.get(
70                  "xss.allow.com.liferay.portal.model.ListType.type"),
71              XSS_ALLOW_BY_MODEL);
72      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
73                  "lock.expiration.time.com.liferay.portal.model.ListTypeModel"));
74  
75      public ListTypeModelImpl() {
76      }
77  
78      public int getPrimaryKey() {
79          return _listTypeId;
80      }
81  
82      public void setPrimaryKey(int pk) {
83          setListTypeId(pk);
84      }
85  
86      public Serializable getPrimaryKeyObj() {
87          return new Integer(_listTypeId);
88      }
89  
90      public int getListTypeId() {
91          return _listTypeId;
92      }
93  
94      public void setListTypeId(int listTypeId) {
95          if (listTypeId != _listTypeId) {
96              _listTypeId = listTypeId;
97          }
98      }
99  
100     public String getName() {
101         return GetterUtil.getString(_name);
102     }
103 
104     public void setName(String name) {
105         if (((name == null) && (_name != null)) ||
106                 ((name != null) && (_name == null)) ||
107                 ((name != null) && (_name != null) && !name.equals(_name))) {
108             if (!XSS_ALLOW_NAME) {
109                 name = XSSUtil.strip(name);
110             }
111 
112             _name = name;
113         }
114     }
115 
116     public String getType() {
117         return GetterUtil.getString(_type);
118     }
119 
120     public void setType(String type) {
121         if (((type == null) && (_type != null)) ||
122                 ((type != null) && (_type == null)) ||
123                 ((type != null) && (_type != null) && !type.equals(_type))) {
124             if (!XSS_ALLOW_TYPE) {
125                 type = XSSUtil.strip(type);
126             }
127 
128             _type = type;
129         }
130     }
131 
132     public Object clone() {
133         ListTypeImpl clone = new ListTypeImpl();
134         clone.setListTypeId(getListTypeId());
135         clone.setName(getName());
136         clone.setType(getType());
137 
138         return clone;
139     }
140 
141     public int compareTo(Object obj) {
142         if (obj == null) {
143             return -1;
144         }
145 
146         ListTypeImpl listType = (ListTypeImpl)obj;
147         int value = 0;
148         value = getName().toLowerCase().compareTo(listType.getName()
149                                                           .toLowerCase());
150 
151         if (value != 0) {
152             return value;
153         }
154 
155         return 0;
156     }
157 
158     public boolean equals(Object obj) {
159         if (obj == null) {
160             return false;
161         }
162 
163         ListTypeImpl listType = null;
164 
165         try {
166             listType = (ListTypeImpl)obj;
167         }
168         catch (ClassCastException cce) {
169             return false;
170         }
171 
172         int pk = listType.getPrimaryKey();
173 
174         if (getPrimaryKey() == pk) {
175             return true;
176         }
177         else {
178             return false;
179         }
180     }
181 
182     public int hashCode() {
183         return (int)getPrimaryKey();
184     }
185 
186     private int _listTypeId;
187     private String _name;
188     private String _type;
189 }