001
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
036 public class ImageCacheModel implements CacheModel<Image>, Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(13);
040
041 sb.append("{imageId=");
042 sb.append(imageId);
043 sb.append(", modifiedDate=");
044 sb.append(modifiedDate);
045 sb.append(", type=");
046 sb.append(type);
047 sb.append(", height=");
048 sb.append(height);
049 sb.append(", width=");
050 sb.append(width);
051 sb.append(", size=");
052 sb.append(size);
053 sb.append("}");
054
055 return sb.toString();
056 }
057
058 public Image toEntityModel() {
059 ImageImpl imageImpl = new ImageImpl();
060
061 imageImpl.setImageId(imageId);
062
063 if (modifiedDate == Long.MIN_VALUE) {
064 imageImpl.setModifiedDate(null);
065 }
066 else {
067 imageImpl.setModifiedDate(new Date(modifiedDate));
068 }
069
070 if (type == null) {
071 imageImpl.setType(StringPool.BLANK);
072 }
073 else {
074 imageImpl.setType(type);
075 }
076
077 imageImpl.setHeight(height);
078 imageImpl.setWidth(width);
079 imageImpl.setSize(size);
080
081 imageImpl.resetOriginalValues();
082
083 return imageImpl;
084 }
085
086 public void readExternal(ObjectInput objectInput) throws IOException {
087 imageId = objectInput.readLong();
088 modifiedDate = objectInput.readLong();
089 type = objectInput.readUTF();
090 height = objectInput.readInt();
091 width = objectInput.readInt();
092 size = objectInput.readInt();
093 }
094
095 public void writeExternal(ObjectOutput objectOutput)
096 throws IOException {
097 objectOutput.writeLong(imageId);
098 objectOutput.writeLong(modifiedDate);
099
100 if (type == null) {
101 objectOutput.writeUTF(StringPool.BLANK);
102 }
103 else {
104 objectOutput.writeUTF(type);
105 }
106
107 objectOutput.writeInt(height);
108 objectOutput.writeInt(width);
109 objectOutput.writeInt(size);
110 }
111
112 public long imageId;
113 public long modifiedDate;
114 public String type;
115 public int height;
116 public int width;
117 public int size;
118 }