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.portlet.messageboards.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    
021    import com.liferay.portlet.messageboards.model.MBMessage;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing MBMessage in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBMessage
035     * @generated
036     */
037    public class MBMessageCacheModel implements CacheModel<MBMessage>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(51);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", messageId=");
046                    sb.append(messageId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", classNameId=");
060                    sb.append(classNameId);
061                    sb.append(", classPK=");
062                    sb.append(classPK);
063                    sb.append(", categoryId=");
064                    sb.append(categoryId);
065                    sb.append(", threadId=");
066                    sb.append(threadId);
067                    sb.append(", rootMessageId=");
068                    sb.append(rootMessageId);
069                    sb.append(", parentMessageId=");
070                    sb.append(parentMessageId);
071                    sb.append(", subject=");
072                    sb.append(subject);
073                    sb.append(", body=");
074                    sb.append(body);
075                    sb.append(", format=");
076                    sb.append(format);
077                    sb.append(", anonymous=");
078                    sb.append(anonymous);
079                    sb.append(", priority=");
080                    sb.append(priority);
081                    sb.append(", allowPingbacks=");
082                    sb.append(allowPingbacks);
083                    sb.append(", answer=");
084                    sb.append(answer);
085                    sb.append(", status=");
086                    sb.append(status);
087                    sb.append(", statusByUserId=");
088                    sb.append(statusByUserId);
089                    sb.append(", statusByUserName=");
090                    sb.append(statusByUserName);
091                    sb.append(", statusDate=");
092                    sb.append(statusDate);
093                    sb.append("}");
094    
095                    return sb.toString();
096            }
097    
098            public MBMessage toEntityModel() {
099                    MBMessageImpl mbMessageImpl = new MBMessageImpl();
100    
101                    if (uuid == null) {
102                            mbMessageImpl.setUuid(StringPool.BLANK);
103                    }
104                    else {
105                            mbMessageImpl.setUuid(uuid);
106                    }
107    
108                    mbMessageImpl.setMessageId(messageId);
109                    mbMessageImpl.setGroupId(groupId);
110                    mbMessageImpl.setCompanyId(companyId);
111                    mbMessageImpl.setUserId(userId);
112    
113                    if (userName == null) {
114                            mbMessageImpl.setUserName(StringPool.BLANK);
115                    }
116                    else {
117                            mbMessageImpl.setUserName(userName);
118                    }
119    
120                    if (createDate == Long.MIN_VALUE) {
121                            mbMessageImpl.setCreateDate(null);
122                    }
123                    else {
124                            mbMessageImpl.setCreateDate(new Date(createDate));
125                    }
126    
127                    if (modifiedDate == Long.MIN_VALUE) {
128                            mbMessageImpl.setModifiedDate(null);
129                    }
130                    else {
131                            mbMessageImpl.setModifiedDate(new Date(modifiedDate));
132                    }
133    
134                    mbMessageImpl.setClassNameId(classNameId);
135                    mbMessageImpl.setClassPK(classPK);
136                    mbMessageImpl.setCategoryId(categoryId);
137                    mbMessageImpl.setThreadId(threadId);
138                    mbMessageImpl.setRootMessageId(rootMessageId);
139                    mbMessageImpl.setParentMessageId(parentMessageId);
140    
141                    if (subject == null) {
142                            mbMessageImpl.setSubject(StringPool.BLANK);
143                    }
144                    else {
145                            mbMessageImpl.setSubject(subject);
146                    }
147    
148                    if (body == null) {
149                            mbMessageImpl.setBody(StringPool.BLANK);
150                    }
151                    else {
152                            mbMessageImpl.setBody(body);
153                    }
154    
155                    if (format == null) {
156                            mbMessageImpl.setFormat(StringPool.BLANK);
157                    }
158                    else {
159                            mbMessageImpl.setFormat(format);
160                    }
161    
162                    mbMessageImpl.setAnonymous(anonymous);
163                    mbMessageImpl.setPriority(priority);
164                    mbMessageImpl.setAllowPingbacks(allowPingbacks);
165                    mbMessageImpl.setAnswer(answer);
166                    mbMessageImpl.setStatus(status);
167                    mbMessageImpl.setStatusByUserId(statusByUserId);
168    
169                    if (statusByUserName == null) {
170                            mbMessageImpl.setStatusByUserName(StringPool.BLANK);
171                    }
172                    else {
173                            mbMessageImpl.setStatusByUserName(statusByUserName);
174                    }
175    
176                    if (statusDate == Long.MIN_VALUE) {
177                            mbMessageImpl.setStatusDate(null);
178                    }
179                    else {
180                            mbMessageImpl.setStatusDate(new Date(statusDate));
181                    }
182    
183                    mbMessageImpl.resetOriginalValues();
184    
185                    return mbMessageImpl;
186            }
187    
188            public void readExternal(ObjectInput objectInput) throws IOException {
189                    uuid = objectInput.readUTF();
190                    messageId = objectInput.readLong();
191                    groupId = objectInput.readLong();
192                    companyId = objectInput.readLong();
193                    userId = objectInput.readLong();
194                    userName = objectInput.readUTF();
195                    createDate = objectInput.readLong();
196                    modifiedDate = objectInput.readLong();
197                    classNameId = objectInput.readLong();
198                    classPK = objectInput.readLong();
199                    categoryId = objectInput.readLong();
200                    threadId = objectInput.readLong();
201                    rootMessageId = objectInput.readLong();
202                    parentMessageId = objectInput.readLong();
203                    subject = objectInput.readUTF();
204                    body = objectInput.readUTF();
205                    format = objectInput.readUTF();
206                    anonymous = objectInput.readBoolean();
207                    priority = objectInput.readDouble();
208                    allowPingbacks = objectInput.readBoolean();
209                    answer = objectInput.readBoolean();
210                    status = objectInput.readInt();
211                    statusByUserId = objectInput.readLong();
212                    statusByUserName = objectInput.readUTF();
213                    statusDate = objectInput.readLong();
214            }
215    
216            public void writeExternal(ObjectOutput objectOutput)
217                    throws IOException {
218                    if (uuid == null) {
219                            objectOutput.writeUTF(StringPool.BLANK);
220                    }
221                    else {
222                            objectOutput.writeUTF(uuid);
223                    }
224    
225                    objectOutput.writeLong(messageId);
226                    objectOutput.writeLong(groupId);
227                    objectOutput.writeLong(companyId);
228                    objectOutput.writeLong(userId);
229    
230                    if (userName == null) {
231                            objectOutput.writeUTF(StringPool.BLANK);
232                    }
233                    else {
234                            objectOutput.writeUTF(userName);
235                    }
236    
237                    objectOutput.writeLong(createDate);
238                    objectOutput.writeLong(modifiedDate);
239                    objectOutput.writeLong(classNameId);
240                    objectOutput.writeLong(classPK);
241                    objectOutput.writeLong(categoryId);
242                    objectOutput.writeLong(threadId);
243                    objectOutput.writeLong(rootMessageId);
244                    objectOutput.writeLong(parentMessageId);
245    
246                    if (subject == null) {
247                            objectOutput.writeUTF(StringPool.BLANK);
248                    }
249                    else {
250                            objectOutput.writeUTF(subject);
251                    }
252    
253                    if (body == null) {
254                            objectOutput.writeUTF(StringPool.BLANK);
255                    }
256                    else {
257                            objectOutput.writeUTF(body);
258                    }
259    
260                    if (format == null) {
261                            objectOutput.writeUTF(StringPool.BLANK);
262                    }
263                    else {
264                            objectOutput.writeUTF(format);
265                    }
266    
267                    objectOutput.writeBoolean(anonymous);
268                    objectOutput.writeDouble(priority);
269                    objectOutput.writeBoolean(allowPingbacks);
270                    objectOutput.writeBoolean(answer);
271                    objectOutput.writeInt(status);
272                    objectOutput.writeLong(statusByUserId);
273    
274                    if (statusByUserName == null) {
275                            objectOutput.writeUTF(StringPool.BLANK);
276                    }
277                    else {
278                            objectOutput.writeUTF(statusByUserName);
279                    }
280    
281                    objectOutput.writeLong(statusDate);
282            }
283    
284            public String uuid;
285            public long messageId;
286            public long groupId;
287            public long companyId;
288            public long userId;
289            public String userName;
290            public long createDate;
291            public long modifiedDate;
292            public long classNameId;
293            public long classPK;
294            public long categoryId;
295            public long threadId;
296            public long rootMessageId;
297            public long parentMessageId;
298            public String subject;
299            public String body;
300            public String format;
301            public boolean anonymous;
302            public double priority;
303            public boolean allowPingbacks;
304            public boolean answer;
305            public int status;
306            public long statusByUserId;
307            public String statusByUserName;
308            public long statusDate;
309    }