1 16 package org.apache.cocoon.environment.http; 17 18 import org.apache.cocoon.environment.Cookie; 19 20 59 60 public final class HttpCookie 61 implements Cookie { 62 63 private javax.servlet.http.Cookie cookie; 64 65 public HttpCookie(String name, String value) { 66 this.cookie = new javax.servlet.http.Cookie (name, value); 67 } 68 69 public HttpCookie(javax.servlet.http.Cookie cookie) { 70 this.cookie = cookie; 71 } 72 73 public javax.servlet.http.Cookie getServletCookie() { 74 this.checkState(); 75 return this.cookie; 76 } 77 78 108 109 public void init(String name, String value) { 110 if (this.cookie == null) { 111 this.cookie = new javax.servlet.http.Cookie (name, value); 112 } else { 113 throw new IllegalStateException ("Cookie is already initialised"); 114 } 115 } 116 117 118 private void checkState() { 119 if (this.cookie == null) { 120 throw new IllegalStateException ("Cookie is not initialised"); 121 } 122 } 123 124 137 138 public void setComment(String purpose) { 139 this.checkState(); 140 this.cookie.setComment(purpose); 141 } 142 143 144 145 146 156 157 public String getComment() { 158 this.checkState(); 159 return this.cookie.getComment(); 160 } 161 162 163 164 165 184 185 public void setDomain(String pattern) { 186 this.checkState(); 187 this.cookie.setDomain(pattern); 188 } 189 190 191 192 193 194 203 204 public String getDomain() { 205 this.checkState(); 206 return this.cookie.getDomain(); 207 } 208 209 210 211 212 234 235 public void setMaxAge(int expiry) { 236 this.checkState(); 237 this.cookie.setMaxAge(expiry); 238 } 239 240 241 242 243 257 258 public int getMaxAge() { 259 this.checkState(); 260 return this.cookie.getMaxAge(); 261 } 262 263 264 265 266 286 287 public void setPath(String uri) { 288 this.checkState(); 289 this.cookie.setPath(uri); 290 } 291 292 293 294 295 307 308 public String getPath() { 309 this.checkState(); 310 return this.cookie.getPath(); 311 } 312 313 314 315 316 317 330 331 public void setSecure(boolean flag) { 332 this.checkState(); 333 this.cookie.setSecure(flag); 334 } 335 336 337 338 339 350 351 public boolean getSecure() { 352 this.checkState(); 353 return this.cookie.getSecure(); 354 } 355 356 357 358 359 360 367 368 public String getName() { 369 this.checkState(); 370 return this.cookie.getName(); 371 } 372 373 374 375 376 377 395 396 public void setValue(String newValue) { 397 this.checkState(); 398 this.cookie.setValue(newValue); 399 } 400 401 402 403 404 414 415 public String getValue() { 416 this.checkState(); 417 return this.cookie.getValue(); 418 } 419 420 421 422 423 438 439 public int getVersion() { 440 this.checkState(); 441 return this.cookie.getVersion(); 442 } 443 444 445 446 447 463 464 public void setVersion(int v) { 465 this.checkState(); 466 this.cookie.setVersion(v); 467 } 468 469 470 471 } 472 473 | Popular Tags |