📄 clickstream.java
字号:
package com.opensymphony.clickstream;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import java.io.Serializable;import java.util.ArrayList;import java.util.Date;import java.util.List;/** * The actual stream of clicks tracked during a user's navigation through a site. * * @author <a href="plightbo@hotmail.com">Patrick Lightbody</a> */public class Clickstream implements Serializable { List clickstream = new ArrayList(); String hostname; HttpSession session; String initialReferrer; Date start = new Date(); Date lastRequest = new Date(); boolean bot = false; public Clickstream() { } /** * Adds a new request to the stream of clicks. The HttpSerlvetRequest is converted * to a ClickstreamRequest object and added to the clickstream. * * @param request The serlvet request to be added to the clickstream */ public void addRequest(HttpServletRequest request) { lastRequest = new Date(); if (hostname == null) { hostname = request.getRemoteHost(); session = request.getSession(); }
// if this is the first request in the click stream
if (clickstream.size() == 0) { // setup initial referrer
if (request.getHeader("REFERER") != null) { initialReferrer = request.getHeader("REFERER"); } else { initialReferrer = ""; }
// decide whether this is a bot
bot = BotChecker.isBot(request, this); } clickstream.add(new ClickstreamRequest(request));
} /** * Returns the host name that this clickstream relates to. * * @return the host name that the user clicked through */ public String getHostname() { return hostname; } /** * Returns the bot status. * * @return true if the client is bot or spider */ public boolean isBot() { return bot; } /** * Returns the HttpSession associated with this clickstream. * * @return the HttpSession associated with this clickstream */ public HttpSession getSession() { return session; } /** * The URL of the initial referer. This is useful for determining * how the user entered the site. * * @return the URL of the initial referer */ public String getInitialReferrer() { return initialReferrer; } /** * Returns the Date when the clickstream began. * * @return the Date when the clickstream began */ public Date getStart() { return start; } /** * Returns the last Date that the clickstream was modified. * * @return the last Date that the clickstream was modified */ public Date getLastRequest() { return lastRequest; } /** * Returns the actual List of ClickstreamRequest objects. * * @return the actual List of ClickstreamRequest objects */ public List getStream() { return clickstream; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -