001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    import com.liferay.portal.model.Image;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing Image in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Image
034     * @generated
035     */
036    public class ImageCacheModel implements CacheModel<Image>, Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(15);
040    
041                    sb.append("{imageId=");
042                    sb.append(imageId);
043                    sb.append(", modifiedDate=");
044                    sb.append(modifiedDate);
045                    sb.append(", text=");
046                    sb.append(text);
047                    sb.append(", type=");
048                    sb.append(type);
049                    sb.append(", height=");
050                    sb.append(height);
051                    sb.append(", width=");
052                    sb.append(width);
053                    sb.append(", size=");
054                    sb.append(size);
055                    sb.append("}");
056    
057                    return sb.toString();
058            }
059    
060            public Image toEntityModel() {
061                    ImageImpl imageImpl = new ImageImpl();
062    
063                    imageImpl.setImageId(imageId);
064    
065                    if (modifiedDate == Long.MIN_VALUE) {
066                            imageImpl.setModifiedDate(null);
067                    }
068                    else {
069                            imageImpl.setModifiedDate(new Date(modifiedDate));
070                    }
071    
072                    if (text == null) {
073                            imageImpl.setText(StringPool.BLANK);
074                    }
075                    else {
076                            imageImpl.setText(text);
077                    }
078    
079                    if (type == null) {
080                            imageImpl.setType(StringPool.BLANK);
081                    }
082                    else {
083                            imageImpl.setType(type);
084                    }
085    
086                    imageImpl.setHeight(height);
087                    imageImpl.setWidth(width);
088                    imageImpl.setSize(size);
089    
090                    imageImpl.resetOriginalValues();
091    
092                    return imageImpl;
093            }
094    
095            public void readExternal(ObjectInput objectInput) throws IOException {
096                    imageId = objectInput.readLong();
097                    modifiedDate = objectInput.readLong();
098                    text = objectInput.readUTF();
099                    type = objectInput.readUTF();
100                    height = objectInput.readInt();
101                    width = objectInput.readInt();
102                    size = objectInput.readInt();
103            }
104    
105            public void writeExternal(ObjectOutput objectOutput)
106                    throws IOException {
107                    objectOutput.writeLong(imageId);
108                    objectOutput.writeLong(modifiedDate);
109    
110                    if (text == null) {
111                            objectOutput.writeUTF(StringPool.BLANK);
112                    }
113                    else {
114                            objectOutput.writeUTF(text);
115                    }
116    
117                    if (type == null) {
118                            objectOutput.writeUTF(StringPool.BLANK);
119                    }
120                    else {
121                            objectOutput.writeUTF(type);
122                    }
123    
124                    objectOutput.writeInt(height);
125                    objectOutput.writeInt(width);
126                    objectOutput.writeInt(size);
127            }
128    
129            public long imageId;
130            public long modifiedDate;
131            public String text;
132            public String type;
133            public int height;
134            public int width;
135            public int size;
136    }