001
014
015 package com.liferay.portal.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.model.CacheModel;
022 import com.liferay.portal.model.Image;
023 import com.liferay.portal.model.MVCCModel;
024
025 import java.io.Externalizable;
026 import java.io.IOException;
027 import java.io.ObjectInput;
028 import java.io.ObjectOutput;
029
030 import java.util.Date;
031
032
039 @ProviderType
040 public class ImageCacheModel implements CacheModel<Image>, Externalizable,
041 MVCCModel {
042 @Override
043 public long getMvccVersion() {
044 return mvccVersion;
045 }
046
047 @Override
048 public void setMvccVersion(long mvccVersion) {
049 this.mvccVersion = mvccVersion;
050 }
051
052 @Override
053 public String toString() {
054 StringBundler sb = new StringBundler(15);
055
056 sb.append("{mvccVersion=");
057 sb.append(mvccVersion);
058 sb.append(", imageId=");
059 sb.append(imageId);
060 sb.append(", modifiedDate=");
061 sb.append(modifiedDate);
062 sb.append(", type=");
063 sb.append(type);
064 sb.append(", height=");
065 sb.append(height);
066 sb.append(", width=");
067 sb.append(width);
068 sb.append(", size=");
069 sb.append(size);
070 sb.append("}");
071
072 return sb.toString();
073 }
074
075 @Override
076 public Image toEntityModel() {
077 ImageImpl imageImpl = new ImageImpl();
078
079 imageImpl.setMvccVersion(mvccVersion);
080 imageImpl.setImageId(imageId);
081
082 if (modifiedDate == Long.MIN_VALUE) {
083 imageImpl.setModifiedDate(null);
084 }
085 else {
086 imageImpl.setModifiedDate(new Date(modifiedDate));
087 }
088
089 if (type == null) {
090 imageImpl.setType(StringPool.BLANK);
091 }
092 else {
093 imageImpl.setType(type);
094 }
095
096 imageImpl.setHeight(height);
097 imageImpl.setWidth(width);
098 imageImpl.setSize(size);
099
100 imageImpl.resetOriginalValues();
101
102 return imageImpl;
103 }
104
105 @Override
106 public void readExternal(ObjectInput objectInput) throws IOException {
107 mvccVersion = objectInput.readLong();
108 imageId = objectInput.readLong();
109 modifiedDate = objectInput.readLong();
110 type = objectInput.readUTF();
111 height = objectInput.readInt();
112 width = objectInput.readInt();
113 size = objectInput.readInt();
114 }
115
116 @Override
117 public void writeExternal(ObjectOutput objectOutput)
118 throws IOException {
119 objectOutput.writeLong(mvccVersion);
120 objectOutput.writeLong(imageId);
121 objectOutput.writeLong(modifiedDate);
122
123 if (type == null) {
124 objectOutput.writeUTF(StringPool.BLANK);
125 }
126 else {
127 objectOutput.writeUTF(type);
128 }
129
130 objectOutput.writeInt(height);
131 objectOutput.writeInt(width);
132 objectOutput.writeInt(size);
133 }
134
135 public long mvccVersion;
136 public long imageId;
137 public long modifiedDate;
138 public String type;
139 public int height;
140 public int width;
141 public int size;
142 }