Home | History | Annotate | Download | only in cookie
      1 /*
      2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/Cookie.java $
      3  * $Revision: 578403 $
      4  * $Date: 2007-09-22 03:56:04 -0700 (Sat, 22 Sep 2007) $
      5  *
      6  * ====================================================================
      7  * Licensed to the Apache Software Foundation (ASF) under one
      8  * or more contributor license agreements.  See the NOTICE file
      9  * distributed with this work for additional information
     10  * regarding copyright ownership.  The ASF licenses this file
     11  * to you under the Apache License, Version 2.0 (the
     12  * "License"); you may not use this file except in compliance
     13  * with the License.  You may obtain a copy of the License at
     14  *
     15  *   http://www.apache.org/licenses/LICENSE-2.0
     16  *
     17  * Unless required by applicable law or agreed to in writing,
     18  * software distributed under the License is distributed on an
     19  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     20  * KIND, either express or implied.  See the License for the
     21  * specific language governing permissions and limitations
     22  * under the License.
     23  * ====================================================================
     24  *
     25  * This software consists of voluntary contributions made by many
     26  * individuals on behalf of the Apache Software Foundation.  For more
     27  * information on the Apache Software Foundation, please see
     28  * <http://www.apache.org/>.
     29  *
     30  */
     31 
     32 package org.apache.http.cookie;
     33 
     34 import java.util.Date;
     35 
     36 /**
     37  * HTTP "magic-cookie" represents a piece of state information
     38  * that the HTTP agent and the target server can exchange to maintain
     39  * a session.
     40  *
     41  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
     42  *
     43  * @since 4.0
     44  */
     45 public interface Cookie {
     46 
     47     /**
     48      * Returns the name.
     49      *
     50      * @return String name The name
     51      */
     52     String getName();
     53 
     54     /**
     55      * Returns the value.
     56      *
     57      * @return String value The current value.
     58      */
     59     String getValue();
     60 
     61     /**
     62      * Returns the comment describing the purpose of this cookie, or
     63      * <tt>null</tt> if no such comment has been defined.
     64      *
     65      * @return comment
     66      */
     67     String getComment();
     68 
     69     /**
     70      * If a user agent (web browser) presents this cookie to a user, the
     71      * cookie's purpose will be described by the information at this URL.
     72      */
     73     String getCommentURL();
     74 
     75     /**
     76      * Returns the expiration {@link Date} of the cookie, or <tt>null</tt>
     77      * if none exists.
     78      * <p><strong>Note:</strong> the object returned by this method is
     79      * considered immutable. Changing it (e.g. using setTime()) could result
     80      * in undefined behaviour. Do so at your peril. </p>
     81      * @return Expiration {@link Date}, or <tt>null</tt>.
     82      */
     83     Date getExpiryDate();
     84 
     85     /**
     86      * Returns <tt>false</tt> if the cookie should be discarded at the end
     87      * of the "session"; <tt>true</tt> otherwise.
     88      *
     89      * @return <tt>false</tt> if the cookie should be discarded at the end
     90      *         of the "session"; <tt>true</tt> otherwise
     91      */
     92     boolean isPersistent();
     93 
     94     /**
     95      * Returns domain attribute of the cookie.
     96      *
     97      * @return the value of the domain attribute
     98      */
     99     String getDomain();
    100 
    101     /**
    102      * Returns the path attribute of the cookie
    103      *
    104      * @return The value of the path attribute.
    105      */
    106     String getPath();
    107 
    108     /**
    109      * Get the Port attribute. It restricts the ports to which a cookie
    110      * may be returned in a Cookie request header.
    111      */
    112     int[] getPorts();
    113 
    114     /**
    115      * Indicates whether this cookie requires a secure connection.
    116      *
    117      * @return  <code>true</code> if this cookie should only be sent
    118      *          over secure connections, <code>false</code> otherwise.
    119      */
    120     boolean isSecure();
    121 
    122     /**
    123      * Returns the version of the cookie specification to which this
    124      * cookie conforms.
    125      *
    126      * @return the version of the cookie.
    127      */
    128     int getVersion();
    129 
    130     /**
    131      * Returns true if this cookie has expired.
    132      * @param date Current time
    133      *
    134      * @return <tt>true</tt> if the cookie has expired.
    135      */
    136     boolean isExpired(final Date date);
    137 
    138 }
    139 
    140