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            public UserTracker toEntityModel() {
064                    UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
065    
066                    userTrackerImpl.setUserTrackerId(userTrackerId);
067                    userTrackerImpl.setCompanyId(companyId);
068                    userTrackerImpl.setUserId(userId);
069    
070                    if (modifiedDate == Long.MIN_VALUE) {
071                            userTrackerImpl.setModifiedDate(null);
072                    }
073                    else {
074                            userTrackerImpl.setModifiedDate(new Date(modifiedDate));
075                    }
076    
077                    if (sessionId == null) {
078                            userTrackerImpl.setSessionId(StringPool.BLANK);
079                    }
080                    else {
081                            userTrackerImpl.setSessionId(sessionId);
082                    }
083    
084                    if (remoteAddr == null) {
085                            userTrackerImpl.setRemoteAddr(StringPool.BLANK);
086                    }
087                    else {
088                            userTrackerImpl.setRemoteAddr(remoteAddr);
089                    }
090    
091                    if (remoteHost == null) {
092                            userTrackerImpl.setRemoteHost(StringPool.BLANK);
093                    }
094                    else {
095                            userTrackerImpl.setRemoteHost(remoteHost);
096                    }
097    
098                    if (userAgent == null) {
099                            userTrackerImpl.setUserAgent(StringPool.BLANK);
100                    }
101                    else {
102                            userTrackerImpl.setUserAgent(userAgent);
103                    }
104    
105                    userTrackerImpl.resetOriginalValues();
106    
107                    return userTrackerImpl;
108            }
109    
110            public void readExternal(ObjectInput objectInput) throws IOException {
111                    userTrackerId = objectInput.readLong();
112                    companyId = objectInput.readLong();
113                    userId = objectInput.readLong();
114                    modifiedDate = objectInput.readLong();
115                    sessionId = objectInput.readUTF();
116                    remoteAddr = objectInput.readUTF();
117                    remoteHost = objectInput.readUTF();
118                    userAgent = objectInput.readUTF();
119            }
120    
121            public void writeExternal(ObjectOutput objectOutput)
122                    throws IOException {
123                    objectOutput.writeLong(userTrackerId);
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(userId);
126                    objectOutput.writeLong(modifiedDate);
127    
128                    if (sessionId == null) {
129                            objectOutput.writeUTF(StringPool.BLANK);
130                    }
131                    else {
132                            objectOutput.writeUTF(sessionId);
133                    }
134    
135                    if (remoteAddr == null) {
136                            objectOutput.writeUTF(StringPool.BLANK);
137                    }
138                    else {
139                            objectOutput.writeUTF(remoteAddr);
140                    }
141    
142                    if (remoteHost == null) {
143                            objectOutput.writeUTF(StringPool.BLANK);
144                    }
145                    else {
146                            objectOutput.writeUTF(remoteHost);
147                    }
148    
149                    if (userAgent == null) {
150                            objectOutput.writeUTF(StringPool.BLANK);
151                    }
152                    else {
153                            objectOutput.writeUTF(userAgent);
154                    }
155            }
156    
157            public long userTrackerId;
158            public long companyId;
159            public long userId;
160            public long modifiedDate;
161            public String sessionId;
162            public String remoteAddr;
163            public String remoteHost;
164            public String userAgent;
165    }