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.portlet.shopping.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="ShoppingItemFieldModelImpl.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>ShoppingItemField</code> table
45   * in the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.shopping.service.model.ShoppingItemField
51   * @see com.liferay.portlet.shopping.service.model.ShoppingItemFieldModel
52   * @see com.liferay.portlet.shopping.service.model.impl.ShoppingItemFieldImpl
53   *
54   */
55  public class ShoppingItemFieldModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "ShoppingItemField";
57      public static Object[][] TABLE_COLUMNS = {
58              { "itemFieldId", new Integer(Types.BIGINT) },
59              { "itemId", new Integer(Types.BIGINT) },
60              { "name", new Integer(Types.VARCHAR) },
61              { "values_", new Integer(Types.VARCHAR) },
62              { "description", new Integer(Types.VARCHAR) }
63          };
64      public static String TABLE_SQL_CREATE = "create table ShoppingItemField (itemFieldId LONG not null primary key,itemId LONG,name VARCHAR(75) null,values_ STRING null,description STRING null)";
65      public static String TABLE_SQL_DROP = "drop table ShoppingItemField";
66      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
67                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingItemField"),
68              XSS_ALLOW);
69      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
70                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingItemField.name"),
71              XSS_ALLOW_BY_MODEL);
72      public static boolean XSS_ALLOW_VALUES = GetterUtil.getBoolean(PropsUtil.get(
73                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingItemField.values"),
74              XSS_ALLOW_BY_MODEL);
75      public static boolean XSS_ALLOW_DESCRIPTION = GetterUtil.getBoolean(PropsUtil.get(
76                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingItemField.description"),
77              XSS_ALLOW_BY_MODEL);
78      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
79                  "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemFieldModel"));
80  
81      public ShoppingItemFieldModelImpl() {
82      }
83  
84      public long getPrimaryKey() {
85          return _itemFieldId;
86      }
87  
88      public void setPrimaryKey(long pk) {
89          setItemFieldId(pk);
90      }
91  
92      public Serializable getPrimaryKeyObj() {
93          return new Long(_itemFieldId);
94      }
95  
96      public long getItemFieldId() {
97          return _itemFieldId;
98      }
99  
100     public void setItemFieldId(long itemFieldId) {
101         if (itemFieldId != _itemFieldId) {
102             _itemFieldId = itemFieldId;
103         }
104     }
105 
106     public long getItemId() {
107         return _itemId;
108     }
109 
110     public void setItemId(long itemId) {
111         if (itemId != _itemId) {
112             _itemId = itemId;
113         }
114     }
115 
116     public String getName() {
117         return GetterUtil.getString(_name);
118     }
119 
120     public void setName(String name) {
121         if (((name == null) && (_name != null)) ||
122                 ((name != null) && (_name == null)) ||
123                 ((name != null) && (_name != null) && !name.equals(_name))) {
124             if (!XSS_ALLOW_NAME) {
125                 name = XSSUtil.strip(name);
126             }
127 
128             _name = name;
129         }
130     }
131 
132     public String getValues() {
133         return GetterUtil.getString(_values);
134     }
135 
136     public void setValues(String values) {
137         if (((values == null) && (_values != null)) ||
138                 ((values != null) && (_values == null)) ||
139                 ((values != null) && (_values != null) &&
140                 !values.equals(_values))) {
141             if (!XSS_ALLOW_VALUES) {
142                 values = XSSUtil.strip(values);
143             }
144 
145             _values = values;
146         }
147     }
148 
149     public String getDescription() {
150         return GetterUtil.getString(_description);
151     }
152 
153     public void setDescription(String description) {
154         if (((description == null) && (_description != null)) ||
155                 ((description != null) && (_description == null)) ||
156                 ((description != null) && (_description != null) &&
157                 !description.equals(_description))) {
158             if (!XSS_ALLOW_DESCRIPTION) {
159                 description = XSSUtil.strip(description);
160             }
161 
162             _description = description;
163         }
164     }
165 
166     public Object clone() {
167         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
168         clone.setItemFieldId(getItemFieldId());
169         clone.setItemId(getItemId());
170         clone.setName(getName());
171         clone.setValues(getValues());
172         clone.setDescription(getDescription());
173 
174         return clone;
175     }
176 
177     public int compareTo(Object obj) {
178         if (obj == null) {
179             return -1;
180         }
181 
182         ShoppingItemFieldImpl shoppingItemField = (ShoppingItemFieldImpl)obj;
183         int value = 0;
184 
185         if (getItemId() < shoppingItemField.getItemId()) {
186             value = -1;
187         }
188         else if (getItemId() > shoppingItemField.getItemId()) {
189             value = 1;
190         }
191         else {
192             value = 0;
193         }
194 
195         if (value != 0) {
196             return value;
197         }
198 
199         value = getName().toLowerCase().compareTo(shoppingItemField.getName()
200                                                                    .toLowerCase());
201 
202         if (value != 0) {
203             return value;
204         }
205 
206         return 0;
207     }
208 
209     public boolean equals(Object obj) {
210         if (obj == null) {
211             return false;
212         }
213 
214         ShoppingItemFieldImpl shoppingItemField = null;
215 
216         try {
217             shoppingItemField = (ShoppingItemFieldImpl)obj;
218         }
219         catch (ClassCastException cce) {
220             return false;
221         }
222 
223         long pk = shoppingItemField.getPrimaryKey();
224 
225         if (getPrimaryKey() == pk) {
226             return true;
227         }
228         else {
229             return false;
230         }
231     }
232 
233     public int hashCode() {
234         return (int)getPrimaryKey();
235     }
236 
237     private long _itemFieldId;
238     private long _itemId;
239     private String _name;
240     private String _values;
241     private String _description;
242 }