001    /**
002     * Copyright (c) 2000-2013 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.UserTracker;
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 UserTracker in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see UserTracker
034     * @generated
035     */
036    public class UserTrackerCacheModel implements CacheModel<UserTracker>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(17);
041    
042                    sb.append("{userTrackerId=");
043                    sb.append(userTrackerId);
044                    sb.append(", companyId=");
045                    sb.append(companyId);
046                    sb.append(", userId=");
047                    sb.append(userId);
048                    sb.append(", modifiedDate=");
049                    sb.append(modifiedDate);
050                    sb.append(", sessionId=");
051                    sb.append(sessionId);
052                    sb.append(", remoteAddr=");
053                    sb.append(remoteAddr);
054                    sb.append(", remoteHost=");
055                    sb.append(remoteHost);
056                    sb.append(", userAgent=");
057                    sb.append(userAgent);
058                    sb.append("}");
059    
060                    return sb.toString();
061            }
062    
063            @Override
064            public UserTracker toEntityModel() {
065                    UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
066    
067                    userTrackerImpl.setUserTrackerId(userTrackerId);
068                    userTrackerImpl.setCompanyId(companyId);
069                    userTrackerImpl.setUserId(userId);
070    
071                    if (modifiedDate == Long.MIN_VALUE) {
072                            userTrackerImpl.setModifiedDate(null);
073                    }
074                    else {
075                            userTrackerImpl.setModifiedDate(new Date(modifiedDate));
076                    }
077    
078                    if (sessionId == null) {
079                            userTrackerImpl.setSessionId(StringPool.BLANK);
080                    }
081                    else {
082                            userTrackerImpl.setSessionId(sessionId);
083                    }
084    
085                    if (remoteAddr == null) {
086                            userTrackerImpl.setRemoteAddr(StringPool.BLANK);
087                    }
088                    else {
089                            userTrackerImpl.setRemoteAddr(remoteAddr);
090                    }
091    
092                    if (remoteHost == null) {
093                            userTrackerImpl.setRemoteHost(StringPool.BLANK);
094                    }
095                    else {
096                            userTrackerImpl.setRemoteHost(remoteHost);
097                    }
098    
099                    if (userAgent == null) {
100                            userTrackerImpl.setUserAgent(StringPool.BLANK);
101                    }
102                    else {
103                            userTrackerImpl.setUserAgent(userAgent);
104                    }
105    
106                    userTrackerImpl.resetOriginalValues();
107    
108                    return userTrackerImpl;
109            }
110    
111            @Override
112            public void readExternal(ObjectInput objectInput) throws IOException {
113                    userTrackerId = objectInput.readLong();
114                    companyId = objectInput.readLong();
115                    userId = objectInput.readLong();
116                    modifiedDate = objectInput.readLong();
117                    sessionId = objectInput.readUTF();
118                    remoteAddr = objectInput.readUTF();
119                    remoteHost = objectInput.readUTF();
120                    userAgent = objectInput.readUTF();
121            }
122    
123            @Override
124            public void writeExternal(ObjectOutput objectOutput)
125                    throws IOException {
126                    objectOutput.writeLong(userTrackerId);
127                    objectOutput.writeLong(companyId);
128                    objectOutput.writeLong(userId);
129                    objectOutput.writeLong(modifiedDate);
130    
131                    if (sessionId == null) {
132                            objectOutput.writeUTF(StringPool.BLANK);
133                    }
134                    else {
135                            objectOutput.writeUTF(sessionId);
136                    }
137    
138                    if (remoteAddr == null) {
139                            objectOutput.writeUTF(StringPool.BLANK);
140                    }
141                    else {
142                            objectOutput.writeUTF(remoteAddr);
143                    }
144    
145                    if (remoteHost == null) {
146                            objectOutput.writeUTF(StringPool.BLANK);
147                    }
148                    else {
149                            objectOutput.writeUTF(remoteHost);
150                    }
151    
152                    if (userAgent == null) {
153                            objectOutput.writeUTF(StringPool.BLANK);
154                    }
155                    else {
156                            objectOutput.writeUTF(userAgent);
157                    }
158            }
159    
160            public long userTrackerId;
161            public long companyId;
162            public long userId;
163            public long modifiedDate;
164            public String sessionId;
165            public String remoteAddr;
166            public String remoteHost;
167            public String userAgent;
168    }