home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / Cookie.java < prev    next >
Text File  |  1997-10-25  |  3KB  |  110 lines

  1. /*  ********************************************************************************
  2.     Cookie.java ********************************************************************
  3.     ********************************************************************************  */
  4.  
  5. package aspcomp;
  6.  
  7. import com.ms.com.*;
  8. import com.ms.asp.*;
  9. import java.util.*;
  10.  
  11. /**
  12.  * This class makes accessing Cookies from Java much simpler.  It combines the ASP
  13.  * IReadCookie and IWriteCookie interfaces into one interface, thereby making the 
  14.  * access less awkward.
  15.  */
  16.  
  17. public class Cookie
  18. {
  19.  
  20. /*  ********************************************************************************
  21.     Constructor ********************************************************************
  22.     ********************************************************************************  */
  23.  
  24.     public Cookie(IReadCookie aspCookie) 
  25.     {
  26.         // Set up the IReadCookie interface, then query it for IWriteCookie
  27.         m_rc = aspCookie;
  28.         m_wc = (IWriteCookie) m_rc;
  29.     }
  30.  
  31.  
  32. /*  ********************************************************************************
  33.     Internal (Private) Variables ***************************************************
  34.     ********************************************************************************  */
  35.  
  36.     private IReadCookie m_rc;
  37.     private IWriteCookie m_wc;
  38.  
  39.  
  40. /*  ********************************************************************************
  41.     External (Public) Methods ******************************************************
  42.     ********************************************************************************  */
  43.  
  44.     public boolean getHasKeys() 
  45.     {
  46.         return m_rc.getHasKeys();
  47.     }
  48.  
  49.     public Enumerator getKeys() 
  50.     {
  51.         return new VariantEnumerator((IEnumVariant) m_rc.get_NewEnum());
  52.     }
  53.  
  54.     public String getItem(String itemName) 
  55.     {
  56.         String strRetVal = null;
  57.  
  58.         try 
  59.         {
  60.             strRetVal = VariantToJava.getString(m_rc.getItem(new Variant(itemName)));
  61.         }
  62.  
  63.         catch (ClassCastException cce) 
  64.         {
  65.             return "";
  66.         }
  67.  
  68.         return strRetVal;
  69.     }
  70.  
  71.     public String getValue() 
  72.     {
  73.         Variant p = new Variant();
  74.         p.noParam();
  75.         return VariantToJava.getString(m_rc.getItem(p));
  76.     }
  77.  
  78.     public void    setDomain(String domainName) 
  79.     {
  80.         m_wc.putDomain(domainName);
  81.     }
  82.  
  83.     public void setExpires(Date d) 
  84.     {
  85.         m_wc.putExpires(JavaToVariant.dateToDouble(d));
  86.     }
  87.     
  88.     public void setItem(String name, String item) 
  89.     {
  90.         m_wc.putItem(new Variant(name), item);
  91.     }
  92.  
  93.     public void setValue(String value) 
  94.     {
  95.         Variant v = new Variant();
  96.         v.noParam();
  97.         m_wc.putItem(v, value);
  98.     }
  99.  
  100.     public void setPath(String path) 
  101.     {
  102.         m_wc.putPath(path);
  103.     }
  104.     
  105.     public void setSecure(boolean secure) 
  106.     {
  107.         m_wc.putSecure(secure);
  108.     }
  109. }
  110.