KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > util > parser > CookieParser


1 package org.apache.turbine.util.parser;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
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,v 1.3.2.2 2004/05/20 03:33:43 seade Exp $
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 JavaDoc 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 JavaDoc request,
91             HttpServletResponse JavaDoc 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 JavaDoc name, String JavaDoc 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 JavaDoc name, String JavaDoc value, int seconds_age);
114
115     /**
116      * Remove a previously set cookie from the client machine.
117      */

118     void unset(String JavaDoc name);
119 }
120
Popular Tags