// Copyright (c) 1999, 2000 Oracle Corporation

package oracle.jbo.common.ampool;

import oracle.jbo.ApplicationModule;

class SessionCookie implements Cloneable
{
   long              mPoolSignature        = 0;
   int               mCookieNum            = -1;
   int               mPassivationId        = -1;
   ApplicationModule mAppModule            = null;
   boolean           mDoActivate           = false;


   SessionCookie(ApplicationPoolImpl amPool)
   {
      mPoolSignature = amPool.getSignature();
      mCookieNum = amPool.getNextCookieNum();
   }


   long getPoolSignature()
   {
      return mPoolSignature;
   }


   int getCookieNum()
   {
      return mCookieNum;
   }

   void setCookieNum(int cookieNum)
   {
      mCookieNum = cookieNum;
   }

   public String toString()
   {
      return String.valueOf(mCookieNum);
   }


   public int hashCode()
   {
      return ((int) mPoolSignature) + mCookieNum;
   }


   public boolean equals(Object obj)
   {
      if (obj != null && obj instanceof SessionCookie)
      {
         if (mPoolSignature == ((SessionCookie)obj).getPoolSignature() &&
             mCookieNum == ((SessionCookie)obj).getCookieNum())
         {
            return true;
         }
      }

      return false;
   }

   protected Object clone() throws CloneNotSupportedException
   {
      return super.clone();
   }

   ApplicationModule getApplicationModule()
   {
      return mAppModule;
   }

   void setApplicationModule(ApplicationModule appModule)
   {
      mAppModule = appModule;
   }
   
   int getPassivationId()
   {
      return mPassivationId;
   }

   void setPassivationId(int passivationId)
   {
      mPassivationId = passivationId;
   }
}
