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  import java.util.Date;
36  
37  /**
38   * <a href="ImageModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>Image</code> table in the database.
47   * </p>
48   *
49   * @author Brian Wing Shun Chan
50   *
51   * @see com.liferay.portal.service.model.Image
52   * @see com.liferay.portal.service.model.ImageModel
53   * @see com.liferay.portal.service.model.impl.ImageImpl
54   *
55   */
56  public class ImageModelImpl extends BaseModelImpl {
57      public static String TABLE_NAME = "Image";
58      public static Object[][] TABLE_COLUMNS = {
59              { "imageId", new Integer(Types.BIGINT) },
60              { "modifiedDate", new Integer(Types.TIMESTAMP) },
61              { "text_", new Integer(Types.CLOB) },
62              { "type_", new Integer(Types.VARCHAR) },
63              { "height", new Integer(Types.INTEGER) },
64              { "width", new Integer(Types.INTEGER) },
65              { "size_", new Integer(Types.INTEGER) }
66          };
67      public static String TABLE_SQL_CREATE = "create table Image (imageId LONG not null primary key,modifiedDate DATE null,text_ TEXT null,type_ VARCHAR(75) null,height INTEGER,width INTEGER,size_ INTEGER)";
68      public static String TABLE_SQL_DROP = "drop table Image";
69      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
70                  "xss.allow.com.liferay.portal.model.Image"), XSS_ALLOW);
71      public static boolean XSS_ALLOW_TEXT = GetterUtil.getBoolean(PropsUtil.get(
72                  "xss.allow.com.liferay.portal.model.Image.text"),
73              XSS_ALLOW_BY_MODEL);
74      public static boolean XSS_ALLOW_TYPE = GetterUtil.getBoolean(PropsUtil.get(
75                  "xss.allow.com.liferay.portal.model.Image.type"),
76              XSS_ALLOW_BY_MODEL);
77      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
78                  "lock.expiration.time.com.liferay.portal.model.ImageModel"));
79  
80      public ImageModelImpl() {
81      }
82  
83      public long getPrimaryKey() {
84          return _imageId;
85      }
86  
87      public void setPrimaryKey(long pk) {
88          setImageId(pk);
89      }
90  
91      public Serializable getPrimaryKeyObj() {
92          return new Long(_imageId);
93      }
94  
95      public long getImageId() {
96          return _imageId;
97      }
98  
99      public void setImageId(long imageId) {
100         if (imageId != _imageId) {
101             _imageId = imageId;
102         }
103     }
104 
105     public Date getModifiedDate() {
106         return _modifiedDate;
107     }
108 
109     public void setModifiedDate(Date modifiedDate) {
110         if (((modifiedDate == null) && (_modifiedDate != null)) ||
111                 ((modifiedDate != null) && (_modifiedDate == null)) ||
112                 ((modifiedDate != null) && (_modifiedDate != null) &&
113                 !modifiedDate.equals(_modifiedDate))) {
114             _modifiedDate = modifiedDate;
115         }
116     }
117 
118     public String getText() {
119         return GetterUtil.getString(_text);
120     }
121 
122     public void setText(String text) {
123         if (((text == null) && (_text != null)) ||
124                 ((text != null) && (_text == null)) ||
125                 ((text != null) && (_text != null) && !text.equals(_text))) {
126             if (!XSS_ALLOW_TEXT) {
127                 text = XSSUtil.strip(text);
128             }
129 
130             _text = text;
131         }
132     }
133 
134     public String getType() {
135         return GetterUtil.getString(_type);
136     }
137 
138     public void setType(String type) {
139         if (((type == null) && (_type != null)) ||
140                 ((type != null) && (_type == null)) ||
141                 ((type != null) && (_type != null) && !type.equals(_type))) {
142             if (!XSS_ALLOW_TYPE) {
143                 type = XSSUtil.strip(type);
144             }
145 
146             _type = type;
147         }
148     }
149 
150     public int getHeight() {
151         return _height;
152     }
153 
154     public void setHeight(int height) {
155         if (height != _height) {
156             _height = height;
157         }
158     }
159 
160     public int getWidth() {
161         return _width;
162     }
163 
164     public void setWidth(int width) {
165         if (width != _width) {
166             _width = width;
167         }
168     }
169 
170     public int getSize() {
171         return _size;
172     }
173 
174     public void setSize(int size) {
175         if (size != _size) {
176             _size = size;
177         }
178     }
179 
180     public Object clone() {
181         ImageImpl clone = new ImageImpl();
182         clone.setImageId(getImageId());
183         clone.setModifiedDate(getModifiedDate());
184         clone.setText(getText());
185         clone.setType(getType());
186         clone.setHeight(getHeight());
187         clone.setWidth(getWidth());
188         clone.setSize(getSize());
189 
190         return clone;
191     }
192 
193     public int compareTo(Object obj) {
194         if (obj == null) {
195             return -1;
196         }
197 
198         ImageImpl image = (ImageImpl)obj;
199         int value = 0;
200 
201         if (getImageId() < image.getImageId()) {
202             value = -1;
203         }
204         else if (getImageId() > image.getImageId()) {
205             value = 1;
206         }
207         else {
208             value = 0;
209         }
210 
211         if (value != 0) {
212             return value;
213         }
214 
215         return 0;
216     }
217 
218     public boolean equals(Object obj) {
219         if (obj == null) {
220             return false;
221         }
222 
223         ImageImpl image = null;
224 
225         try {
226             image = (ImageImpl)obj;
227         }
228         catch (ClassCastException cce) {
229             return false;
230         }
231 
232         long pk = image.getPrimaryKey();
233 
234         if (getPrimaryKey() == pk) {
235             return true;
236         }
237         else {
238             return false;
239         }
240     }
241 
242     public int hashCode() {
243         return (int)getPrimaryKey();
244     }
245 
246     private long _imageId;
247     private Date _modifiedDate;
248     private String _text;
249     private String _type;
250     private int _height;
251     private int _width;
252     private int _size;
253 }