public class Session extends Object implements Comparable<Session>, SessionContext
| Modifier and Type | Field and Description |
|---|---|
static int |
COOKIE_BASED |
static int |
HEURISTIC_BASED |
static int |
PARAMETER_BASED |
| Constructor and Description |
|---|
Session(int type,
String id,
AuditEvent evt)
Creates a new session with the given session-identifier and the first
event of the session being
evt. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(AuditEvent e) |
int |
compareTo(Session s)
This compares the session to
s. |
boolean |
equals(Object o) |
Date |
firstAccessed() |
String |
getId()
This method returns an unique identifier that serves as a key to this session.
|
InetAddress |
getInetAddress() |
double |
getScore() |
int |
getType()
Returns wether this session context is tracked based on a Session-Id in
Cookies, Parameters or just heuristically using ip, time and user-agent.
|
String |
getVariable(String name)
This method returns the string-value of the variable given by
name. |
Set<String> |
getVariableNames()
This method returns a set of variable names (strings) that are set within the session scope
and did not expire yet.
|
int |
hashCode() |
void |
increment(String var,
int count)
This method will increment the count of the variable
var by the
amount of count. |
Date |
lastAccessed() |
void |
removeVariable(String name)
This method shall remove the variable with the given name from the session-context.
|
void |
setInetAddress(InetAddress addr) |
void |
setScore(double d) |
void |
setVariable(String name,
String value,
Date expires)
This method creates a new variable with the given name and initializes it to the
value provided by
value. |
String |
toString() |
public static final int COOKIE_BASED
public static final int PARAMETER_BASED
public static final int HEURISTIC_BASED
public Session(int type,
String id,
AuditEvent evt)
evt. Start time of the session
is the date for evt.type - The type which denotes the kind of session-tracker by which
the session is created.public int getType()
public void setInetAddress(InetAddress addr)
addr - public InetAddress getInetAddress()
public Date lastAccessed()
public Date firstAccessed()
public String getId()
SessionContextgetId in interface SessionContextpublic void addEvent(AuditEvent e)
e - public int compareTo(Session s)
s. Basically this is just a comparison
of the session-identifiers and results in a lexikographical order of sessions based
on ther session-ids.compareTo in interface Comparable<Session>s - s, or +1/-1 if it is ordered before/after s.public double getScore()
public void setScore(double d)
public String getVariable(String name)
SessionContextname. If no such
variable exists within this session, null is returned.getVariable in interface SessionContextname or null if the
variable does not exist.public Set<String> getVariableNames()
SessionContextgetVariableNames in interface SessionContextpublic void increment(String var, int count)
SessionContextvar by the
amount of count. If the variable is a non-numeric one, calling this
method will have no effect.increment in interface SessionContextpublic void setVariable(String name, String value, Date expires)
SessionContextvalue. The variable will expire at the given date or
as the session itself expires.
By providing a null value for the date, the variable will be set to
expire at the sessions end.setVariable in interface SessionContextpublic void removeVariable(String name)
SessionContextremoveVariable in interface SessionContextCopyright © 2013 jwall.org. All Rights Reserved.