1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/*
Wotonomy: OpenStep design patterns for pure Java applications.
Copyright (C) 2000 Blacksmith, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see http://www.gnu.org
*/
package net.wotonomy.web;
import net.wotonomy.foundation.NSDate;
/**
* A pure java implementation of WOCookie that extends
* javax.servlet.httpd.Cookie for greater compatibility.
*
* @author michael@mpowers.net
* @author $Author: cgruber $
* @version $Revision: 905 $
*/
public class WOCookie extends javax.servlet.http.Cookie {
/**
* Default constructor.
*/
public WOCookie() {
super("", "");
}
/**
* Constructs a cookie with the specified name and value.
*/
public WOCookie(String aName, String aValue) {
super(aName, aValue);
}
/**
* Constructs a cookie with the specified name and value. Also sets the path to
* the current application's path.
*/
public static WOCookie cookieWithName(String aName, String aValue) {
WOCookie result = new WOCookie(aName, aValue);
// TODO: Set the path to the current application's path.
return result;
}
/**
* Constructs a cookie with the specified attributes.
*/
public static WOCookie cookieWithName(String aName, String aValue, String aPath, String aDomain,
NSDate expirationDate, boolean secure) {
WOCookie result = new WOCookie(aName, aValue);
result.setPath(aPath);
result.setDomain(aDomain);
result.setExpires(expirationDate);
result.setSecure(secure);
return result;
}
/**
* Returns the name of the cookie.
*/
public String name() {
return this.getName();
}
/**
* Sets the name of the cookie.
*/
public void setName(String aString) {
// super.setName( aString );
throw new RuntimeException("Not yet implemented.");
}
/**
* Returns the value of the cookie.
*/
public String value() {
return this.getValue();
}
/**
* Sets the value of the cookie.
*/
public void setValue(String aString) {
super.setValue(aString);
}
/**
* Gets the domain of the cookie.
*/
public String domain() {
return this.getDomain();
}
/**
* Sets the domain of the cookie.
*/
public void setDomain(String aString) {
super.setDomain(aString);
}
/**
* Gets the path of the cookie.
*/
public String path() {
return this.getPath();
}
/**
* Sets the path of the cookie.
*/
public void setPath(String aString) {
super.setPath(aString);
}
/**
* Gets the expiration date of the cookie. If in the past, the cookie will
* persist until browser shutdown.
*/
public NSDate expires() {
return new NSDate(this.getMaxAge());
}
/**
* Sets the expiration date of the cookie.
*/
public void setExpires(NSDate aDate) {
this.setMaxAge((int) aDate.timeIntervalSinceNow());
}
/**
* Returns whether the cookie will only be sent over a secure protocol.
*/
public boolean isSecure() {
return this.getSecure();
}
/**
* Sets whether the cookie will only be sent over a secure protocol.
*/
public void setIsSecure(boolean isSecure) {
this.setSecure(isSecure);
}
/**
* Returns the string as it appears in the HTTP header of the response. This
* would normally be called by WOResponse, but is handled automatically by the
* servlet implementation.
*/
public String headerString() {
new RuntimeException("Not implemented yet.");
return null;
}
}
/*
* $Log$ Revision 1.2 2006/02/19 01:44:02 cgruber Add xmlrpc files Remove jclark
* and replace with dom4j and javax.xml.sax stuff Re-work dependencies and
* imports so it all compiles.
*
* Revision 1.1 2006/02/16 13:22:22 cgruber Check in all sources in
* eclipse-friendly maven-enabled packages.
*
* Revision 1.1.1.1 2000/12/21 15:53:04 mpowers Contributing wotonomy.
*
* Revision 1.2 2000/12/20 16:25:50 michael Added log to all files.
*
*
*/
|