be.unamur.inference.web
Class UserSession<T extends UserRequest>

java.lang.Object
  extended by be.unamur.inference.web.UserSession<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
ApacheUserSession

public class UserSession<T extends UserRequest>
extends Object
implements Iterable<T>

Represents a sequence of UserRequests. Each request follow the previous one in time.

Author:
Xavier Devroey - xavier.devroey@unamur.be

Field Summary
protected  Date endTime
          The end time of the sequence.
protected  Date startTime
          The start time of the sequence.
 
Constructor Summary
UserSession(String userId)
          Creates a new session for the user identified by the given id.
 
Method Summary
 void enqueue(T request)
          Add a new request to the session.
 Date getEndTime()
          Returns the end time of the sequence.
 Date getStartTime()
          Returns the start time of the sequence.
 String getUserId()
          Returns the id of the user who issued this request.
 Iterator<T> iterator()
           
 void setUserId(String userId)
          Set the id of the user who issued this request.
 int size()
          Returns the number of requests in the session.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startTime

protected Date startTime
The start time of the sequence. Corresponds to the time of the first request of the sequence.


endTime

protected Date endTime
The end time of the sequence. Corresponds to the time of the last request of the sequence.

Constructor Detail

UserSession

public UserSession(String userId)
Creates a new session for the user identified by the given id.

Parameters:
userId - The id of the user issuing the requests of the session.
Method Detail

getUserId

public String getUserId()
Returns the id of the user who issued this request.


setUserId

public void setUserId(String userId)
Set the id of the user who issued this request.

Parameters:
userId - The new user's id.

getStartTime

public Date getStartTime()
Returns the start time of the sequence. Corresponds to the time of the first request of the sequence.


getEndTime

public Date getEndTime()
Returns the end time of the sequence. Corresponds to the time of the last request of the sequence.


size

public int size()
Returns the number of requests in the session.


toString

public String toString()
Overrides:
toString in class Object

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T extends UserRequest>

enqueue

public void enqueue(T request)
Add a new request to the session. Requests have to be added using chronological order in the session.

Parameters:
request - The request to add. Has to be later than the last request added to the session (request.getTime() > this.getEndTime() ).


Copyright © 2014 PReCISE, University of Namur. All rights reserved.