1   /**
2    * Copyright (c) 2000-2008 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.Image;
29  import com.liferay.portal.model.ImageSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="ImageModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>Image</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.service.model.Image
58   * @see com.liferay.portal.service.model.ImageModel
59   * @see com.liferay.portal.service.model.impl.ImageImpl
60   *
61   */
62  public class ImageModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "Image";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "imageId", new Integer(Types.BIGINT) },
66              
67  
68              { "modifiedDate", new Integer(Types.TIMESTAMP) },
69              
70  
71              { "text_", new Integer(Types.CLOB) },
72              
73  
74              { "type_", new Integer(Types.VARCHAR) },
75              
76  
77              { "height", new Integer(Types.INTEGER) },
78              
79  
80              { "width", new Integer(Types.INTEGER) },
81              
82  
83              { "size_", new Integer(Types.INTEGER) }
84          };
85      public static final 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)";
86      public static final String TABLE_SQL_DROP = "drop table Image";
87      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
88                  "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
89              true);
90  
91      public static Image toModel(ImageSoap soapModel) {
92          Image model = new ImageImpl();
93  
94          model.setImageId(soapModel.getImageId());
95          model.setModifiedDate(soapModel.getModifiedDate());
96          model.setText(soapModel.getText());
97          model.setType(soapModel.getType());
98          model.setHeight(soapModel.getHeight());
99          model.setWidth(soapModel.getWidth());
100         model.setSize(soapModel.getSize());
101 
102         return model;
103     }
104 
105     public static List<Image> toModels(ImageSoap[] soapModels) {
106         List<Image> models = new ArrayList<Image>(soapModels.length);
107 
108         for (ImageSoap soapModel : soapModels) {
109             models.add(toModel(soapModel));
110         }
111 
112         return models;
113     }
114 
115     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
116                 "lock.expiration.time.com.liferay.portal.model.Image"));
117 
118     public ImageModelImpl() {
119     }
120 
121     public long getPrimaryKey() {
122         return _imageId;
123     }
124 
125     public void setPrimaryKey(long pk) {
126         setImageId(pk);
127     }
128 
129     public Serializable getPrimaryKeyObj() {
130         return new Long(_imageId);
131     }
132 
133     public long getImageId() {
134         return _imageId;
135     }
136 
137     public void setImageId(long imageId) {
138         if (imageId != _imageId) {
139             _imageId = imageId;
140         }
141     }
142 
143     public Date getModifiedDate() {
144         return _modifiedDate;
145     }
146 
147     public void setModifiedDate(Date modifiedDate) {
148         if (((modifiedDate == null) && (_modifiedDate != null)) ||
149                 ((modifiedDate != null) && (_modifiedDate == null)) ||
150                 ((modifiedDate != null) && (_modifiedDate != null) &&
151                 !modifiedDate.equals(_modifiedDate))) {
152             _modifiedDate = modifiedDate;
153         }
154     }
155 
156     public String getText() {
157         return GetterUtil.getString(_text);
158     }
159 
160     public void setText(String text) {
161         if (((text == null) && (_text != null)) ||
162                 ((text != null) && (_text == null)) ||
163                 ((text != null) && (_text != null) && !text.equals(_text))) {
164             _text = text;
165         }
166     }
167 
168     public String getType() {
169         return GetterUtil.getString(_type);
170     }
171 
172     public void setType(String type) {
173         if (((type == null) && (_type != null)) ||
174                 ((type != null) && (_type == null)) ||
175                 ((type != null) && (_type != null) && !type.equals(_type))) {
176             _type = type;
177         }
178     }
179 
180     public int getHeight() {
181         return _height;
182     }
183 
184     public void setHeight(int height) {
185         if (height != _height) {
186             _height = height;
187         }
188     }
189 
190     public int getWidth() {
191         return _width;
192     }
193 
194     public void setWidth(int width) {
195         if (width != _width) {
196             _width = width;
197         }
198     }
199 
200     public int getSize() {
201         return _size;
202     }
203 
204     public void setSize(int size) {
205         if (size != _size) {
206             _size = size;
207         }
208     }
209 
210     public Image toEscapedModel() {
211         if (isEscapedModel()) {
212             return (Image)this;
213         }
214         else {
215             Image model = new ImageImpl();
216 
217             model.setEscapedModel(true);
218 
219             model.setImageId(getImageId());
220             model.setModifiedDate(getModifiedDate());
221             model.setText(HtmlUtil.escape(getText()));
222             model.setType(HtmlUtil.escape(getType()));
223             model.setHeight(getHeight());
224             model.setWidth(getWidth());
225             model.setSize(getSize());
226 
227             model = (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
228                     new Class[] { Image.class }, new ReadOnlyBeanHandler(model));
229 
230             return model;
231         }
232     }
233 
234     public Object clone() {
235         ImageImpl clone = new ImageImpl();
236 
237         clone.setImageId(getImageId());
238         clone.setModifiedDate(getModifiedDate());
239         clone.setText(getText());
240         clone.setType(getType());
241         clone.setHeight(getHeight());
242         clone.setWidth(getWidth());
243         clone.setSize(getSize());
244 
245         return clone;
246     }
247 
248     public int compareTo(Object obj) {
249         if (obj == null) {
250             return -1;
251         }
252 
253         ImageImpl image = (ImageImpl)obj;
254 
255         int value = 0;
256 
257         if (getImageId() < image.getImageId()) {
258             value = -1;
259         }
260         else if (getImageId() > image.getImageId()) {
261             value = 1;
262         }
263         else {
264             value = 0;
265         }
266 
267         if (value != 0) {
268             return value;
269         }
270 
271         return 0;
272     }
273 
274     public boolean equals(Object obj) {
275         if (obj == null) {
276             return false;
277         }
278 
279         ImageImpl image = null;
280 
281         try {
282             image = (ImageImpl)obj;
283         }
284         catch (ClassCastException cce) {
285             return false;
286         }
287 
288         long pk = image.getPrimaryKey();
289 
290         if (getPrimaryKey() == pk) {
291             return true;
292         }
293         else {
294             return false;
295         }
296     }
297 
298     public int hashCode() {
299         return (int)getPrimaryKey();
300     }
301 
302     private long _imageId;
303     private Date _modifiedDate;
304     private String _text;
305     private String _type;
306     private int _height;
307     private int _width;
308     private int _size;
309 }