KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > beans > Clickstream


1 package com.dotmarketing.beans;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.ArrayList JavaDoc;
5 import java.util.Collections JavaDoc;
6 import java.util.Date JavaDoc;
7 import java.util.HashMap JavaDoc;
8 import java.util.List JavaDoc;
9 import java.util.Map JavaDoc;
10 import java.util.Set JavaDoc;
11
12 /**
13  * The actual stream of clicks tracked during a user's navigation through a site.
14  *
15  * @author <a HREF="plightbo@hotmail.com">Patrick Lightbody</a>
16  */

17 public class Clickstream implements Serializable JavaDoc {
18     
19     private static final long serialVersionUID = 1L;
20     @SuppressWarnings JavaDoc("unchecked")
21     private List JavaDoc clickstreamRequests = Collections.synchronizedList(new ArrayList JavaDoc());
22     private long clickstreamId;
23     private Map JavaDoc attributes = new HashMap JavaDoc();
24     private String JavaDoc hostname;
25     private String JavaDoc userId;
26     private String JavaDoc cookieId;
27     private String JavaDoc remoteAddress;
28     private String JavaDoc initialReferrer;
29     private String JavaDoc userAgent;
30     private Date JavaDoc start = new Date JavaDoc();
31     private Date JavaDoc lastRequest = new Date JavaDoc();
32     private boolean bot = false;
33
34
35     public Clickstream() {
36         
37     }
38
39     /**
40      * Gets an attribute for this clickstream.
41      *
42      * @param name
43      */

44     public Object JavaDoc getAttribute(String JavaDoc name) {
45         return attributes.get(name);
46     }
47
48     /**
49      * Gets the attribute names for this clickstream.
50      */

51     public Set JavaDoc getAttributeNames() {
52         return attributes.keySet();
53     }
54
55     /**
56      * Sets an attribute for this clickstream.
57      *
58      * @param name
59      * @param value
60      */

61     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
62         attributes.put(name, value);
63     }
64
65     /**
66      * Returns the host name that this clickstream relates to.
67      *
68      * @return the host name that the user clicked through
69      */

70     public String JavaDoc getHostname() {
71       return hostname;
72     }
73
74     /**
75      * Returns the bot status.
76      *
77      * @return true if the client is bot or spider
78      */

79     public boolean isBot() {
80         return bot;
81     }
82
83      /**
84      * The URL of the initial referer. This is useful for determining
85      * how the user entered the site.
86      *
87      * @return the URL of the initial referer
88      */

89     public String JavaDoc getInitialReferrer() {
90         return initialReferrer;
91     }
92
93     /**
94      * Returns the Date when the clickstream began.
95      *
96      * @return the Date when the clickstream began
97      */

98     public Date JavaDoc getStart() {
99         return start;
100     }
101
102     /**
103      * Returns the last Date that the clickstream was modified.
104      *
105      * @return the last Date that the clickstream was modified
106      */

107     public Date JavaDoc getLastRequest() {
108         return lastRequest;
109     }
110
111     /**
112      * Returns the actual List of ClickstreamRequest objects.
113      *
114      * @return the actual List of ClickstreamRequest objects
115      */

116
117
118     /**
119      * @return Returns the cookie.
120      */

121     public String JavaDoc getCookieId() {
122         return cookieId;
123     }
124     /**
125      * @param cookie The cookie to set.
126      */

127     public void setCookieId(String JavaDoc cookieId) {
128         this.cookieId = cookieId;
129     }
130     /**
131      * @return Returns the id.
132      */

133     public long getClickstreamId() {
134         return clickstreamId;
135     }
136     /**
137      * @param id The id to set.
138      */

139     public void setClickstreamId(long clickstreamId) {
140         this.clickstreamId = clickstreamId;
141     }
142     /**
143      * @return Returns the userId.
144      */

145     public String JavaDoc getUserId() {
146         return userId;
147     }
148     /**
149      * @param userId The userId to set.
150      */

151     public void setUserId(String JavaDoc userId) {
152         this.userId = userId;
153     }
154     /**
155      * @param bot The bot to set.
156      */

157     public void setBot(boolean bot) {
158         this.bot = bot;
159     }
160     /**
161      * @param clickstreamRequests The clickstreamRequests to set.
162      */

163     public void setClickstreamRequests(List JavaDoc clickstreamRequests) {
164         this.clickstreamRequests = clickstreamRequests;
165     }
166     /**
167      * @param clickstreamRequests The clickstreamRequests to add.
168      */

169     public void addClickstreamRequest(ClickstreamRequest clickstreamRequest) {
170         clickstreamRequests.add(clickstreamRequest);
171     }
172     /**
173      * @param hostname The hostname to set.
174      */

175     public void setHostname(String JavaDoc hostname) {
176         this.hostname = hostname;
177     }
178     /**
179      * @param initialReferrer The initialReferrer to set.
180      */

181     public void setInitialReferrer(String JavaDoc initialReferrer) {
182         if(initialReferrer.length()>255){
183             initialReferrer = initialReferrer.substring(0,254);
184         }
185         this.initialReferrer = initialReferrer;
186     }
187     /**
188      * @param lastRequest The lastRequest to set.
189      */

190     public void setLastRequest(Date JavaDoc lastRequest) {
191         this.lastRequest = lastRequest;
192     }
193     /**
194      * @param start The start to set.
195      */

196     public void setStart(Date JavaDoc start) {
197         this.start = start;
198     }
199     
200     /**
201      * @return Returns the clickstreamRequests.
202      */

203     public List JavaDoc getClickstreamRequests() {
204         return clickstreamRequests;
205     }
206
207
208
209
210     /**
211      * @return Returns the userAgent.
212      */

213     public String JavaDoc getUserAgent() {
214         return userAgent;
215     }
216     /**
217      * @param userAgent The userAgent to set.
218      */

219     public void setUserAgent(String JavaDoc userAgent) {
220         if(userAgent!=null && userAgent.length()>255){
221             userAgent = userAgent.substring(0,254);
222         }
223         this.userAgent = userAgent;
224     }
225     /**
226      * @return Returns the remoteAddress.
227      */

228     public String JavaDoc getRemoteAddress() {
229         return remoteAddress;
230     }
231     /**
232      * @param remoteAddress The remoteAddress to set.
233      */

234     public void setRemoteAddress(String JavaDoc remoteAddress) {
235         this.remoteAddress = remoteAddress;
236     }
237 }
238
239
240
Popular Tags