1 30 31 package org.apache.commons.httpclient.cookie; 32 33 import java.util.Date ; 34 35 import org.apache.commons.httpclient.Cookie; 36 37 48 public class Cookie2 extends Cookie { 49 50 public static final String DOMAIN = "domain"; 52 public static final String PATH = "path"; 53 public static final String PORT = "port"; 54 public static final String VERSION = "version"; 55 public static final String SECURE = "secure"; 56 public static final String MAXAGE = "max-age"; 57 public static final String COMMENT = "comment"; 58 public static final String COMMENTURL = "commenturl"; 59 public static final String DISCARD = "discard"; 60 61 64 public Cookie2() { 65 super(null, "noname", null, null, null, false); 66 } 67 68 75 public Cookie2(String domain, String name, String value) { 76 super(domain, name, value); 77 } 78 79 96 public Cookie2(String domain, String name, String value, 97 String path, Date expires, boolean secure) { 98 super(domain, name, value, path, expires, secure); 99 } 100 101 120 public Cookie2(String domain, String name, String value, 121 String path, Date expires, boolean secure, int[] ports) { 122 super(domain, name, value, path, expires, secure); 123 setPorts(ports); 124 } 125 126 132 public String getCommentURL() { 133 return cookieCommentURL; 134 } 135 136 144 public void setCommentURL(String commentURL) { 145 this.cookieCommentURL = commentURL; 146 } 147 148 154 public int[] getPorts() { 155 return cookiePorts; 156 } 157 158 166 public void setPorts(int[] ports) { 167 this.cookiePorts = ports; 168 } 169 170 177 public void setDiscard(boolean toDiscard) { 178 discard = toDiscard; 179 } 180 181 188 public boolean isPersistent() { 189 return (null != getExpiryDate()) && !discard; 190 } 191 192 201 public void setPortAttributeSpecified(boolean value) { 202 hasPortAttribute = value; 203 } 204 205 211 public boolean isPortAttributeSpecified() { 212 return hasPortAttribute; 213 } 214 215 229 public void setPortAttributeBlank(boolean value) { 230 isPortAttributeBlank = value; 231 } 232 233 239 public boolean isPortAttributeBlank() { 240 return isPortAttributeBlank; 241 } 242 243 251 public void setVersionAttributeSpecified(boolean value) { 252 hasVersionAttribute = value; 253 } 254 255 261 public boolean isVersionAttributeSpecified() { 262 return hasVersionAttribute; 263 } 264 265 270 public String toExternalForm() { 271 CookieSpec spec = 272 CookiePolicy.getCookieSpec(CookiePolicy.RFC_2965); 273 return spec.formatCookie(this); 274 } 275 276 279 private String cookieCommentURL; 280 281 284 private int[] cookiePorts; 285 286 289 private boolean discard = false; 290 291 295 private boolean hasPortAttribute = false; 296 297 301 private boolean isPortAttributeBlank = false; 302 303 306 private boolean hasVersionAttribute = false; 307 308 309 } 310 311 | Popular Tags |