1 /* 2 * Copyright 2012 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the 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 public interface Cookie extends Comparable<Cookie> { 24 25 /** 26 * Returns the name of this cookie. 27 */ 28 String getName(); 29 30 /** 31 * Returns the value of this cookie. 32 */ 33 String getValue(); 34 35 /** 36 * Sets the value of this cookie. 37 */ 38 void setValue(String value); 39 40 /** 41 * Returns the domain of this cookie. 42 */ 43 String getDomain(); 44 45 /** 46 * Sets the domain of this cookie. 47 */ 48 void setDomain(String domain); 49 50 /** 51 * Returns the path of this cookie. 52 */ 53 String getPath(); 54 55 /** 56 * Sets the path of this cookie. 57 */ 58 void setPath(String path); 59 60 /** 61 * Returns the comment of this cookie. 62 */ 63 String getComment(); 64 65 /** 66 * Sets the comment of this cookie. 67 */ 68 void setComment(String comment); 69 70 /** 71 * Returns the max age of this cookie in seconds. 72 */ 73 int getMaxAge(); 74 75 /** 76 * Sets the max age of this cookie in seconds. If {@code 0} is specified, 77 * this cookie will be removed by browser because it will be expired 78 * immediately. If {@link Integer#MIN_VALUE} is specified, this cookie will be removed 79 * when a user terminates browser. 80 */ 81 void setMaxAge(int maxAge); 82 83 /** 84 * Returns the version of this cookie. 85 */ 86 int getVersion(); 87 88 /** 89 * Sets the version of this cookie. 90 */ 91 void setVersion(int version); 92 93 /** 94 * Returns the secure flag of this cookie. 95 */ 96 boolean isSecure(); 97 98 /** 99 * Sets the secure flag of this cookie. 100 */ 101 void setSecure(boolean secure); 102 103 /** 104 * Returns if this cookie cannot be accessed through client side script. 105 * This flag works only if the browser supports it. For more information, 106 * see <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>. 107 */ 108 boolean isHttpOnly(); 109 110 /** 111 * Sets if this cookie cannot be accessed through client side script. 112 * This flag works only if the browser supports it. For more information, 113 * see <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>. 114 */ 115 void setHttpOnly(boolean httpOnly); 116 117 /** 118 * Returns the comment URL of this cookie. 119 */ 120 String getCommentUrl(); 121 122 /** 123 * Sets the comment URL of this cookie. 124 */ 125 void setCommentUrl(String commentUrl); 126 127 /** 128 * Returns the discard flag of this cookie. 129 */ 130 boolean isDiscard(); 131 132 /** 133 * Sets the discard flag of this cookie. 134 */ 135 void setDiscard(boolean discard); 136 137 /** 138 * Returns the ports of this cookie. 139 */ 140 Set<Integer> getPorts(); 141 142 /** 143 * Sets the ports of this cookie. 144 */ 145 void setPorts(int... ports); 146 147 /** 148 * Sets the ports of this cookie. 149 */ 150 void setPorts(Iterable<Integer> ports); 151 }