View Javadoc

1   /*
2    * Copyright 2009 Red Hat, Inc.
3    *
4    * Red Hat licenses this file to you under the Apache License, version 2.0
5    * (the "License"); you may not use this file except in compliance with the
6    * License.  You may obtain a copy of the License at:
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http;
17  
18  import java.util.Set;
19  
20  /**
21   * An HTTP <a href="http://en.wikipedia.org/wiki/HTTP_cookie">Cookie</a>.
22   *
23   * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
24   * @author <a href="http://gleamynode.net/">Trustin Lee</a>
25   * @author Andy Taylor (andy.taylor@jboss.org)
26   * @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
27   */
28  public interface Cookie extends Comparable<Cookie> {
29  
30      /**
31       * Returns the name of this cookie.
32       */
33      String getName();
34  
35      /**
36       * Returns the value of this cookie.
37       */
38      String getValue();
39  
40      /**
41       * Sets the value of this cookie.
42       */
43      void setValue(String value);
44  
45      /**
46       * Returns the domain of this cookie.
47       */
48      String getDomain();
49  
50      /**
51       * Sets the domain of this cookie.
52       */
53      void setDomain(String domain);
54  
55      /**
56       * Returns the path of this cookie.
57       */
58      String getPath();
59  
60      /**
61       * Sets the path of this cookie.
62       */
63      void setPath(String path);
64  
65      /**
66       * Returns the comment of this cookie.
67       */
68      String getComment();
69  
70      /**
71       * Sets the comment of this cookie.
72       */
73      void setComment(String comment);
74  
75      /**
76       * Returns the max age of this cookie in seconds.
77       */
78      int getMaxAge();
79  
80      /**
81       * Sets the max age of this cookie in seconds.  If {@code 0} is specified,
82       * this cookie will be removed by browser because it will be expired
83       * immediately.  If {@code -1} is specified, this cookie will be removed
84       * when a user terminates browser.
85       */
86      void setMaxAge(int maxAge);
87  
88      /**
89       * Returns the version of this cookie.
90       */
91      int getVersion();
92  
93      /**
94       * Sets the version of this cookie.
95       */
96      void setVersion(int version);
97  
98      /**
99       * Returns the secure flag of this cookie.
100      */
101     boolean isSecure();
102 
103     /**
104      * Sets the secure flag of this cookie.
105      */
106     void setSecure(boolean secure);
107 
108     /**
109      * Returns if this cookie cannot be accessed through client side script.
110      * This flag works only if the browser supports it.  For more information,
111      * see <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>.
112      */
113     boolean isHttpOnly();
114 
115     /**
116      * Sets if this cookie cannot be accessed through client side script.
117      * This flag works only if the browser supports it.  For more information,
118      * see <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>.
119      */
120     void setHttpOnly(boolean httpOnly);
121 
122     /**
123      * Returns the comment URL of this cookie.
124      */
125     String getCommentUrl();
126 
127     /**
128      * Sets the comment URL of this cookie.
129      */
130     void setCommentUrl(String commentUrl);
131 
132     /**
133      * Returns the discard flag of this cookie.
134      */
135     boolean isDiscard();
136 
137     /**
138      * Sets the discard flag of this cookie.
139      */
140     void setDiscard(boolean discard);
141 
142     /**
143      * Returns the ports of this cookie.
144      */
145     Set<Integer> getPorts();
146 
147     /**
148      * Sets the ports of this cookie.
149      */
150     void setPorts(int... ports);
151 
152     /**
153      * Sets the ports of this cookie.
154      */
155     void setPorts(Iterable<Integer> ports);
156 }