org.walluck.oscar
Class MsgCookie

java.lang.Object
  extended byorg.walluck.oscar.MsgCookie

public class MsgCookie
extends java.lang.Object

'C' is for cookie, and also for caching.

Since:
1.0
Version:
1.0
Author:
David Walluck

Constructor Summary
MsgCookie()
          Create a cookie and add the cookie to the cookie cache automatically.
MsgCookie(AIMConnection conn, byte[] cookie, int type, java.lang.Object data)
          Create a cookie and add the cookie to the cookie cache automatically.
MsgCookie(AIMConnection conn, byte[] cookie, int type, java.lang.Object data, boolean toc)
          Create a TOC-compatible cookie and add the cookie to the cookie cache automatically.
 
Method Summary
static void cacheCookie(AIMConnection conn, MsgCookie cookie)
          Add a cookie to the cookie cache.
static MsgCookie checkCookie(AIMConnection conn, MsgCookie cookie)
          Check if the given cookie is in the cookie cache.
 boolean equals(java.lang.Object obj)
          Tests the current cookie and the given cookie for equality.
static byte[] genCookie(boolean toc)
          Generate a cookie.
 long getAddTime()
          Get the value of addTime.
 byte[] getCookie()
          Get the value of cookie.
 java.lang.Object getData()
          Get the value of data.
 int getType()
          Get the value of type.
 int getType(int reqClass)
          Get the cookie type based on the given capability.
 int hashCode()
          The hashcode.
 void setAddTime(long addTime)
          Set the value of addTime.
 void setCookie(byte[] cookie)
          Set the value of cookie.
 void setData(java.lang.Object data)
          Set the value of data.
 void setType(int type)
          Set the value of type.
static MsgCookie uncacheCookie(AIMConnection conn, MsgCookie cookie)
          Get a cookie from the cookie cache and remove it from the cookie cache.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MsgCookie

public MsgCookie()
Create a cookie and add the cookie to the cookie cache automatically.


MsgCookie

public MsgCookie(AIMConnection conn,
                 byte[] cookie,
                 int type,
                 java.lang.Object data)
Create a cookie and add the cookie to the cookie cache automatically.

Parameters:
conn - the connection
cookie - the cookie
type - the cookie type
data - the cookie data

MsgCookie

public MsgCookie(AIMConnection conn,
                 byte[] cookie,
                 int type,
                 java.lang.Object data,
                 boolean toc)
Create a TOC-compatible cookie and add the cookie to the cookie cache automatically. A TOC-compatible cookie contains only alpha-numeric values.

Parameters:
conn - the connection
cookie - the cookie
type - the cookie type
data - the cookie data
toc - set to true if you want TOC-compatible, false otherwise
Method Detail

genCookie

public static byte[] genCookie(boolean toc)
Generate a cookie.

Parameters:
toc - set to true for TOC-compatible, false otherwise
Returns:
the cookie

getCookie

public byte[] getCookie()
Get the value of cookie.

Returns:
value of cookie.

setCookie

public void setCookie(byte[] cookie)
Set the value of cookie.

Parameters:
cookie - Value to assign to cookie.

getType

public int getType()
Get the value of type.

Returns:
value of type.

setType

public void setType(int type)
Set the value of type.

Parameters:
type - Value to assign to type.

getData

public java.lang.Object getData()
Get the value of data.

Returns:
value of data.

setData

public void setData(java.lang.Object data)
Set the value of data.

Parameters:
data - Value to assign to data.

getAddTime

public long getAddTime()
Get the value of addTime.

Returns:
value of addTime.

setAddTime

public void setAddTime(long addTime)
Set the value of addTime.

Parameters:
addTime - Value to assign to addTime.

cacheCookie

public static void cacheCookie(AIMConnection conn,
                               MsgCookie cookie)
Add a cookie to the cookie cache.

If the cookie is found, update the addtime of the cached cookie, otherwise add it to the cache.

Parameters:
conn - the connection
cookie - the MessageCookie

uncacheCookie

public static MsgCookie uncacheCookie(AIMConnection conn,
                                      MsgCookie cookie)
Get a cookie from the cookie cache and remove it from the cookie cache.

Parameters:
conn - the connection
cookie - the MessageCookie
Returns:
the cookie if found, or else null

checkCookie

public static MsgCookie checkCookie(AIMConnection conn,
                                    MsgCookie cookie)
Check if the given cookie is in the cookie cache.

Parameters:
conn - the connection
cookie - the MessageCookie
Returns:
the cookie if found, or else null

getType

public int getType(int reqClass)
Get the cookie type based on the given capability.

Parameters:
reqClass - the capability flag
Returns:
the cookie type

equals

public boolean equals(java.lang.Object obj)
Tests the current cookie and the given cookie for equality.

Parameters:
obj - the cookie to test
Returns:
true if they match, false otherwise

hashCode

public int hashCode()
The hashcode.

Returns:
the hashcode