1 package org.apache.turbine.util.parser;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21
22 import org.apache.turbine.util.RunData;
23 import org.apache.turbine.util.uri.URI;
24
25 /***
26 * CookieParser is an interface to a utility to to get and set values
27 * of Cookies on the Client Browser. You can use CookieParser to convert
28 * Cookie values to various types or to set Bean values with setParameters().
29 * Servlet Spec for more information on Cookies.
30 * <p>
31 * Use set() or unset() to Create or Destroy Cookies.
32 * <p>
33 * NOTE: The name= portion of a name=value pair may be converted
34 * to lowercase or uppercase when the object is initialized and when
35 * new data is added. This behaviour is determined by the url.case.folding
36 * property in TurbineResources.properties. Adding a name/value pair may
37 * overwrite existing name=value pairs if the names match:
38 *
39 * <pre>
40 * CookieParser cp = data.getCookies();
41 * cp.add("ERROR",1);
42 * cp.add("eRrOr",2);
43 * int result = cp.getInt("ERROR");
44 * </pre>
45 *
46 * In the above example, result is 2.
47 *
48 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
49 * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
50 * @version $Id: CookieParser.java 264148 2005-08-29 14:21:04Z henning $
51 */
52 public interface CookieParser
53 extends ValueParser
54 {
55 int AGE_SESSION = -1;
56 int AGE_DELETE = 0;
57
58 /***
59 * Gets the parsed RunData.
60 *
61 * @return the parsed RunData object or null.
62 * @deprecated. Don't use the Run Data object. use getRequest().
63 */
64 RunData getRunData();
65
66 /***
67 * Gets the Request Object for this parser.
68 *
69 * @return the HttpServletRequest or null.
70 */
71 HttpServletRequest getRequest();
72
73 /***
74 * Sets the RunData to be parsed.
75 * All previous cookies will be cleared.
76 *
77 * @param data the RunData object.
78 * @deprecated. Use setData (HttpServletRequest request, HttpServletResponse response) instead
79 */
80 void setRunData(RunData data);
81
82 /***
83 * Sets Request and Response to be parsed.
84 *
85 * All previous cookies will be cleared.
86 *
87 * @param request The http request from the servlet
88 * @param response The http reponse from the servlet
89 */
90 void setData(HttpServletRequest request,
91 HttpServletResponse response);
92
93 /***
94 * Get the Path where cookies will be stored
95 */
96 URI getCookiePath();
97
98 /***
99 * Set the path for cookie storage
100 */
101 void setCookiePath(URI path);
102
103 /***
104 * Set a cookie that will be stored on the client for
105 * the duration of the session.
106 */
107 void set(String name, String value);
108
109 /***
110 * Set a persisten cookie on the client that will expire
111 * after a maximum age (given in seconds).
112 */
113 void set(String name, String value, int seconds_age);
114
115 /***
116 * Remove a previously set cookie from the client machine.
117 */
118 void unset(String name);
119 }