Open SiteSearch 4.1.1
Final

ORG.oclc.jassi
Class UserStateObject

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--ORG.oclc.jassi.UserStateObject

public class UserStateObject
extends Hashtable

The UserStateObject class contains persistent user state data that is maintained for the user's session. Temporary user state data is maintained only for the current thread transaction. There is one UserStateObject object per user in the system.

The UserStateObject class extends Hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.

The UserStateObject class provides methods that allow for the storage and retreival of objects from the hashtable.

These examples show how to store and retreive user state objects:

(1) The first example shows the storage of the key dbname in the hashtable with the associated WorldCat String value. An entity &dbname; can be set in an HTML page and will be substituted the the corresponding hashtable String value WorldCat.

user.put("dbname", "WorldCat");
String currentdbname = (String) user.get("dbname");

(2) The second example shows the storage of the key recordnumber in the hashtable with the associated integer value 10.

user.put("recordnumber", 10);
int currentRecordNum = user.getInt("recordnumber");

(3) The third example shows the storage of the key tmpHash in the hashtable with the associated Hashtable object. This example demonstrates that any type of object can be stored in the user state hashtable.

Hashtable t = new Hashtable(10);
user.put("tmpHash", t);
Hashtable tHash = (Hashtable) user.get("tmpHash");

See Also:
JaSSI, UserApplicationContext, UserHistory, Verb, UserLog, Serialized Form

Field Summary
 Log out
          Log object for writing JaSSI user logs.
static int PROTECTED
           
static int RONLY
           
static int UNPROTECTED
           
 String userId
          String containing the user's sessionid.
 
Constructor Summary
UserStateObject(String sessionId)
          Constructs a UserStateObject object using the input parameter sessionid.
 
Method Summary
 Hashtable applicationContext()
          Returns a hashtable containing the UserApplicationContext objects.
 boolean containsKey(Object name)
          Tests if the specified object is a key in this hashtable.
 void delete()
          Removes this user and all associated data with this user from the system.
 Object get(Object name)
          Returns the value to which the specified input key is mapped in this hashtable.
 Object get(Object name, RequestManager rMngr)
           
 boolean getBoolean(Object name)
          Returns the boolean value to which the specified input key is mapped in this hashtable.
 DataPairs getHttpMsg()
          Returns a DataPairs object containing the user's current transaction HTTP request.
 int getInt(Object name)
          Returns the integer value to which the specified input key is mapped in this hashtable.
 int getInt(Object name, int defaultVal)
          Returns the integer value to which the specified input key is mapped in this hashtable or a default integer value if the key is not mapped to any value.
 long getLastTxnTime()
          Returns the long value of the user's last transaction timestamp.
 Vector getPUP()
          Returns a Vector containing the names of all the persistent user profile items
 Object getSync(String key)
          Returns the syncronization state for the User for a particular Thread.
 int getSyncInt(String key)
          Returns the syncronization state for the User for a particular Thread.
 String getSyncString(String key)
          Returns the syncronization state for the User for a particular Thread as a String.
 String getTempSessionDir()
          Returns the String value of the directory root for temporary files used during a session.
static int getTraceLevel()
          Returns the current trace level (i.e.
 Vector history()
          Returns the Vector object containing the list of UserHistory objects.
 boolean isSync(String key, int syncMode)
          Sets the syncronization state for the User for a particular Thread.
 void openLog(int traceLevel)
          Opens the user log file if it is not already opened and sets the trace level to the specified input integer value.
 Log out()
          Returns the user Log object.
 Object put(Object name, boolean value)
          Maps the specified input key to the specified input boolean value.
 Object put(Object name, int value)
          Maps the specified input key to the specified input integer value.
 Object put(Object name, Object obj)
          Maps the specified input key to the specified input object value.
 Object putPUD(String name, DataDir d)
          Deprecated. Use putPUP method instead.
 Object putPUD(String name, String obj)
          Deprecated. Use putPUP method instead.
 Object putPUP(Object name, Object obj)
          Adds the name of a piece of profile data to the pups (a list of names of profile data) and also puts the piece of data into the UserStateObject with the name supplied.
 Object remove(Object name)
          Removes the specified input key and its corresponding value from this hashtable.
 Object removePUD(String name)
          Deprecated. Use removePUP method instead.
 Object removePUP(Object name)
          Removes the name of a piece of profile data from the pups (a list of names of profile data).
 void removeSync(String key)
          Removes the syncronization state for the User for a particular Thread.
static void setCapacity(int c)
          Sets the initial UserStateObject hashtable size to the specified input integer value.
 void setLastTxnTime()
          Sets the user's last transaction timestamp to the current millisecond.
static void setLogClass(String c)
          Sets the user log file class to the specified input class name.
static void setLogDir(String d)
          Sets the user log file directory to the specified input directory.
static void setLogName(String name)
          Sets the user log file name to the specified input name.
 void setOverrideHash(Hashtable oh)
          Sets the value of overrideHash
 void setSync(String key, int syncMode)
          Sets the syncronization state for the User for a particular Thread.
static void setTempDirRoot(String s)
          Sets the directory root for temporary files used during a session to the specified input directory root.
 void setTimeout(int t)
          Sets the timeout period for user idle session timeouts using the integer input parameter t.
 void setTimeout(long t)
          Sets the timeout period for user idle session timeouts using the long input parameter t.
static void setTraceLevel(int t)
          Sets the user trace level to the specified input integer value.
 int tempSizeData()
          Returns the integer size of the temporary thread hashtable for this user's current transaction thread.
 long timeout()
          Returns an integer containing the timeout period for the user.
 String toString()
          Generates the String representation of this object.
 String toString(String separator)
          Generates the String representation of this object given the specified input String separator value used to terminate each entry.
 void writeStats()
          Invokes the write method in the user stats object and passes the user and the user's history objects to it.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

out

public Log out
Log object for writing JaSSI user logs.

userId

public String userId
String containing the user's sessionid.

RONLY

public static final int RONLY

PROTECTED

public static final int PROTECTED

UNPROTECTED

public static final int UNPROTECTED
Constructor Detail

UserStateObject

public UserStateObject(String sessionId)
Constructs a UserStateObject object using the input parameter sessionid.
Parameters:
sessionId - the sessionid for this user.
Method Detail

getSync

public Object getSync(String key)
Returns the syncronization state for the User for a particular Thread.
Parameters:
key - the lock string (e.g., threadId).
Returns:
 

getSyncInt

public int getSyncInt(String key)
Returns the syncronization state for the User for a particular Thread.
Parameters:
key - the lock string (e.g., threadId).
Returns:
int - the integer representation of the user's sync state or -1 if get it fails.

getSyncString

public String getSyncString(String key)
Returns the syncronization state for the User for a particular Thread as a String.
Parameters:
key - the lock string (e.g., threadId).
Returns:
String the name of the mode (RONLY, PROTECTED, UNPROTECTED) "null" if get it fails.

isSync

public boolean isSync(String key,
                      int syncMode)
Sets the syncronization state for the User for a particular Thread.
Parameters:
key - the lock string (e.g., threadId).
syncMode - the mode to place the user in RONLY, PROTECETED, or UNPROTECTED.

removeSync

public void removeSync(String key)
Removes the syncronization state for the User for a particular Thread.
Parameters:
key - the lock string (e.g., threadId).

setSync

public void setSync(String key,
                    int syncMode)
Sets the syncronization state for the User for a particular Thread.
Parameters:
key - the lock string (e.g., threadId).
syncMode - the mode to place the user in RONLY, PROTECETED, or UNPROTECTED.

history

public Vector history()
Returns the Vector object containing the list of UserHistory objects.
Returns:
the Vector object containing the list of UserHistory objects.

out

public final Log out()
Returns the user Log object.
Returns:
the user Log object.

setCapacity

public static final void setCapacity(int c)
Sets the initial UserStateObject hashtable size to the specified input integer value.
Parameters:
c - the initial size of the UserStateObject hashtable.

setTimeout

public final void setTimeout(int t)
Sets the timeout period for user idle session timeouts using the integer input parameter t.
Parameters:
t - the number of seconds for the idle session timeout period.

timeout

public final long timeout()
Returns an integer containing the timeout period for the user.
Returns:
int

setTimeout

public final void setTimeout(long t)
Sets the timeout period for user idle session timeouts using the long input parameter t.
Parameters:
t - the number of milliseconds for the idle session timeout period.

setLastTxnTime

public final void setLastTxnTime()
Sets the user's last transaction timestamp to the current millisecond.

getLastTxnTime

public final long getLastTxnTime()
Returns the long value of the user's last transaction timestamp.
Returns:
the long value of the user's last timestamp in milliseconds.

setLogName

public static final void setLogName(String name)
Sets the user log file name to the specified input name.
Parameters:
name - the user log file name.

setLogDir

public static final void setLogDir(String d)
Sets the user log file directory to the specified input directory.
Parameters:
d - the user log file directory.

setLogClass

public static final void setLogClass(String c)
Sets the user log file class to the specified input class name.
Parameters:
c - the user log file class name.

setTempDirRoot

public static final void setTempDirRoot(String s)
Sets the directory root for temporary files used during a session to the specified input directory root.
Parameters:
s - the temporary directory root.

getTempSessionDir

public final String getTempSessionDir()
Returns the String value of the directory root for temporary files used during a session.
Returns:
the String value of the temporary directory root.

getHttpMsg

public final DataPairs getHttpMsg()
Returns a DataPairs object containing the user's current transaction HTTP request.
Returns:
the DataPairs object containing the HTTP request for this user's current transaction.

setTraceLevel

public static final void setTraceLevel(int t)
Sets the user trace level to the specified input integer value.
Parameters:
t - the user trace level integer value.

getTraceLevel

public static int getTraceLevel()
Returns the current trace level (i.e. the default trace level for new user sessions)
Returns:
the current trace level (i.e. the default trace level for new user sessions)

applicationContext

public Hashtable applicationContext()
Returns a hashtable containing the UserApplicationContext objects.
Returns:
a hashtable containing the UserApplicationContext objects.

openLog

public void openLog(int traceLevel)
Opens the user log file if it is not already opened and sets the trace level to the specified input integer value.
Parameters:
traceLevel - the trace level integer value for the user logs.

delete

public void delete()
Removes this user and all associated data with this user from the system.

put

public final Object put(Object name,
                        Object obj)
Maps the specified input key to the specified input object value.
Parameters:
name - the hashtable key.
obj - the value.
Returns:
the previous value of the specified input key in this hashtable; or null if it did not have one.
Overrides:
put in class Hashtable

put

public final Object put(Object name,
                        int value)
Maps the specified input key to the specified input integer value.
Parameters:
name - the hashtable key.
obj - the integer value.
Returns:
the previous value of the specified input key in this hashtable; or null if it did not have one.

put

public final Object put(Object name,
                        boolean value)
Maps the specified input key to the specified input boolean value.
Parameters:
name - the hashtable key.
obj - the boolean value.
Returns:
the previous value of the specified input key in this hashtable; or null if it did not have one.

getPUP

public Vector getPUP()
Returns a Vector containing the names of all the persistent user profile items
Returns:
contains the names of pup in the user

putPUP

public final Object putPUP(Object name,
                           Object obj)
Adds the name of a piece of profile data to the pups (a list of names of profile data) and also puts the piece of data into the UserStateObject with the name supplied.
Parameters:
name - the name of the profile information
obj - the value of the profile information
Returns:
the previous value of the key, if it existed, or the current value

removePUP

public final Object removePUP(Object name)
Removes the name of a piece of profile data from the pups (a list of names of profile data). It also removes the piece of data from the UserStateObject.
Parameters:
name - the name of the profile information
Returns:
the previous value of the key

removePUD

public final Object removePUD(String name)
Deprecated. Use removePUP method instead.
Removes the name of a piece of profile data from the Persistant User Data (PUD) vector (a list of names of profile data). It also removes the piece of data from the UserStateObject.
Parameters:
name - the name of the profile information
Returns:
the previous value of the key

putPUD

public final Object putPUD(String name,
                           String obj)
Deprecated. Use putPUP method instead.
Adds the name of a piece of profile data to the Persistant User Data (PUD) vector (a list of names of profile data) and also puts the piece of data into the UserStateObject with the name supplied.
Parameters:
name - the name of the profile information
obj - the String value of the profile information
Returns:
the previous value of the key, if it existed, or the current value

putPUD

public final Object putPUD(String name,
                           DataDir d)
Deprecated. Use putPUP method instead.
Adds the name of a piece of profile data to the Persistant User Data (PUD) vector (a list of names of profile data) and also puts the piece of data into the UserStateObject with the name supplied.
Parameters:
name - the name of the profile information
d - the DataDir of the profile information
Returns:
the previous value of the key, if it existed, or the current value

get

public final Object get(Object name)
Returns the value to which the specified input key is mapped in this hashtable.
Parameters:
name - the hashtable key.
Returns:
the value to which the key is mapped in this hashtable; or null if the key is not mapped to any value in this hashtable.
Overrides:
get in class Hashtable

get

public final Object get(Object name,
                        RequestManager rMngr)

setOverrideHash

public final void setOverrideHash(Hashtable oh)
Sets the value of overrideHash
Parameters:
oh - overrideHash

getInt

public final int getInt(Object name,
                        int defaultVal)
Returns the integer value to which the specified input key is mapped in this hashtable or a default integer value if the key is not mapped to any value.
Parameters:
name - a key in the hashtable.
defValue - the default integer value.
Returns:
the integer value to which the key is mapped in this hashtable; or the default integer value if the key is not mapped to any value in this hashtable.

getInt

public final int getInt(Object name)
                 throws NullPointerException,
                        ClassCastException
Returns the integer value to which the specified input key is mapped in this hashtable.
Parameters:
name - a key in the hashtable.
Returns:
the integer value to which the key is mapped in this hashtable; or throws an exception if the key is mapped to a non-integer value.
Throws:
NullPointerException - if object key is not found.
ClassCastException - if object is not an integer.

getBoolean

public final boolean getBoolean(Object name)
Returns the boolean value to which the specified input key is mapped in this hashtable.
Parameters:
name - a key in the hashtable.
Returns:
the boolean value to which the key is mapped in this hashtable; or false if the key is mapped to any other non-boolean value or is null.

remove

public final Object remove(Object name)
Removes the specified input key and its corresponding value from this hashtable.
Parameters:
name - the key in the hashtable.
Returns:
the value to which the key had been mapped in this hashtable; or null if the key did not have a mapping.
Overrides:
remove in class Hashtable

containsKey

public boolean containsKey(Object name)
Tests if the specified object is a key in this hashtable.
Parameters:
name - the key in the hashtable.
Returns:
true if the specified object is a key in this hashtable; false otherwise.
Overrides:
containsKey in class Hashtable

tempSizeData

public int tempSizeData()
Returns the integer size of the temporary thread hashtable for this user's current transaction thread.
Returns:
the integer size of the temporary thread hashtable.

toString

public String toString(String separator)
Generates the String representation of this object given the specified input String separator value used to terminate each entry.
Parameters:
entry - String separator value. (i.e.: break or newline)
Returns:
the String representation of this object using the input separator value.

toString

public String toString()
Generates the String representation of this object.
Returns:
the String representation of this object.
Overrides:
toString in class Hashtable

writeStats

public final void writeStats()
Invokes the write method in the user stats object and passes the user and the user's history objects to it.

Open SiteSearch 4.1.1
Final