src/share/classes/java/net/CookieManager.java

Print this page




 140     /**
 141      * Create a new cookie manager with specified cookie store and cookie policy.
 142      *
 143      * @param store     a <tt>CookieStore</tt> to be used by cookie manager.
 144      *                  if <tt>null</tt>, cookie manager will use a default one,
 145      *                  which is an in-memory CookieStore implmentation.
 146      * @param cookiePolicy      a <tt>CookiePolicy</tt> instance
 147      *                          to be used by cookie manager as policy callback.
 148      *                          if <tt>null</tt>, ACCEPT_ORIGINAL_SERVER will
 149      *                          be used.
 150      */
 151     public CookieManager(CookieStore store,
 152                          CookiePolicy cookiePolicy)
 153     {
 154         // use default cookie policy if not specify one
 155         policyCallback = (cookiePolicy == null) ? CookiePolicy.ACCEPT_ORIGINAL_SERVER
 156                                                 : cookiePolicy;
 157 
 158         // if not specify CookieStore to use, use default one
 159         if (store == null) {
 160             cookieJar = new sun.net.www.protocol.http.InMemoryCookieStore();
 161         } else {
 162             cookieJar = store;
 163         }
 164     }
 165 
 166 
 167     /* ---------------- Public operations -------------- */
 168 
 169     /**
 170      * To set the cookie policy of this cookie manager.
 171      *
 172      * <p> A instance of <tt>CookieManager</tt> will have
 173      * cookie policy ACCEPT_ORIGINAL_SERVER by default. Users always
 174      * can call this method to set another cookie policy.
 175      *
 176      * @param cookiePolicy      the cookie policy. Can be <tt>null</tt>, which
 177      *                          has no effects on current cookie policy.
 178      */
 179     public void setCookiePolicy(CookiePolicy cookiePolicy) {
 180         if (cookiePolicy != null) policyCallback = cookiePolicy;




 140     /**
 141      * Create a new cookie manager with specified cookie store and cookie policy.
 142      *
 143      * @param store     a <tt>CookieStore</tt> to be used by cookie manager.
 144      *                  if <tt>null</tt>, cookie manager will use a default one,
 145      *                  which is an in-memory CookieStore implmentation.
 146      * @param cookiePolicy      a <tt>CookiePolicy</tt> instance
 147      *                          to be used by cookie manager as policy callback.
 148      *                          if <tt>null</tt>, ACCEPT_ORIGINAL_SERVER will
 149      *                          be used.
 150      */
 151     public CookieManager(CookieStore store,
 152                          CookiePolicy cookiePolicy)
 153     {
 154         // use default cookie policy if not specify one
 155         policyCallback = (cookiePolicy == null) ? CookiePolicy.ACCEPT_ORIGINAL_SERVER
 156                                                 : cookiePolicy;
 157 
 158         // if not specify CookieStore to use, use default one
 159         if (store == null) {
 160             cookieJar = new InMemoryCookieStore();
 161         } else {
 162             cookieJar = store;
 163         }
 164     }
 165 
 166 
 167     /* ---------------- Public operations -------------- */
 168 
 169     /**
 170      * To set the cookie policy of this cookie manager.
 171      *
 172      * <p> A instance of <tt>CookieManager</tt> will have
 173      * cookie policy ACCEPT_ORIGINAL_SERVER by default. Users always
 174      * can call this method to set another cookie policy.
 175      *
 176      * @param cookiePolicy      the cookie policy. Can be <tt>null</tt>, which
 177      *                          has no effects on current cookie policy.
 178      */
 179     public void setCookiePolicy(CookiePolicy cookiePolicy) {
 180         if (cookiePolicy != null) policyCallback = cookiePolicy;