001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: Request.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: import java.util.Enumeration;
011: import java.util.Locale;
012: import java.util.Map;
013: import javax.servlet.RequestDispatcher;
014: import javax.servlet.http.Cookie;
015: import javax.servlet.http.HttpServletRequest;
016: import javax.servlet.http.HttpSession;
017:
018: /**
019: * This interface contains all the methods that the web engine needs to be
020: * able to correctly handle incoming requests.
021: *
022: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
023: * @version $Revision: 3634 $
024: * @since 1.1
025: */
026: public interface Request {
027: /**
028: * Initialize the state of this request from a <code>StateStore</code>.
029: * <p>This method is only there to be used by the web engine, it should
030: * never be called manually.
031: *
032: * @param stateStore the <code>StateStore</code> that will be used to
033: * initialize the request
034: * @since 1.1
035: */
036: public void init(StateStore stateStore);
037:
038: /**
039: * See {@link HttpServletRequest#getMethod()}.
040: *
041: * @since 1.1
042: */
043: public RequestMethod getMethod();
044:
045: /**
046: * Retrieves the parameters that were sent in this request.
047: *
048: * @return a <code>Map</code> with all the parameter names and values
049: * @since 1.1
050: */
051: public Map<String, String[]> getParameters();
052:
053: /**
054: * Retrieves the files that were uploaded in this request.
055: *
056: * @return a <code>Map</code> with all the uploaded files
057: * @see #hasFile(String)
058: * @see #getFile(String)
059: * @see #getFiles(String)
060: * @since 1.1
061: */
062: public Map<String, UploadedFile[]> getFiles();
063:
064: /**
065: * Checks if a particular file has been uploaded in this request.
066: *
067: * @param name the name of the file, as declared in the submission
068: * @return <code>true</code> if the file was uploaded; or
069: * <p><code>false</code> otherwise
070: * @see #getFiles()
071: * @see #getFile(String)
072: * @see #getFiles(String)
073: * @since 1.1
074: */
075: public boolean hasFile(String name);
076:
077: /**
078: * Retrieves an uploaded file.
079: *
080: * @param name the name of the file, as declared in the submission
081: * @return the uploaded file; or
082: * <p><code>null</code> if no file was uploaded
083: * @see #getFiles()
084: * @see #hasFile(String)
085: * @see #getFiles(String)
086: * @since 1.1
087: */
088: public UploadedFile getFile(String name);
089:
090: /**
091: * Retrieves all files that have been uploaded for a particular name.
092: *
093: * @param name the name of the file, as declared in the submission
094: * @return the uploaded files; or
095: * <p><code>null</code> if no files were uploaded for that name
096: * @see #getFiles()
097: * @see #hasFile(String)
098: * @see #getFile(String)
099: * @since 1.1
100: */
101: public UploadedFile[] getFiles(String name);
102:
103: /**
104: * Returns the root URL of the server that is running this web
105: * applications.
106: * <p>This includes the protocol, the server name and the server port, for
107: * example: <code>http://www.somehost.com:8080</code>.
108: *
109: * @return the server's root url
110: * @since 1.1
111: */
112: public String getServerRootUrl(int port);
113:
114: /**
115: * Checks whether a cookie is present.
116: *
117: * @param name the name of the cookie
118: * @return <code>true</code> if the cookie was present; or
119: * <p><code>false</code> otherwise
120: * @see #getCookie(String)
121: * @see #getCookies()
122: * @since 1.1
123: */
124: public boolean hasCookie(String name);
125:
126: /**
127: * Retrieves a cookie.
128: *
129: * @param name the name of the cookie.
130: * @return the instance of the cookie; or
131: * <p><code>null</code> if no such cookie is present
132: * @see #hasCookie(String)
133: * @see #getCookies()
134: * @since 1.1
135: */
136: public Cookie getCookie(String name);
137:
138: /**
139: * See {@link HttpServletRequest#getCookies()}.
140: *
141: * @since 1.1
142: */
143: public Cookie[] getCookies();
144:
145: /**
146: * See {@link HttpServletRequest#getAttribute(String)}.
147: *
148: * @since 1.1
149: */
150: public Object getAttribute(String name);
151:
152: /**
153: * Checks if a request attribute exists.
154: *
155: * @param name a <code>String</code> specifying the name of the attribute
156: * <p><code>false</code> otherwise
157: * @since 1.1
158: */
159: public boolean hasAttribute(String name);
160:
161: /**
162: * See {@link HttpServletRequest#getAttributeNames()}.
163: *
164: * @since 1.1
165: */
166: public Enumeration getAttributeNames();
167:
168: /**
169: * See {@link HttpServletRequest#removeAttribute(String)}.
170: *
171: * @since 1.1
172: */
173: public void removeAttribute(String name);
174:
175: /**
176: * See {@link HttpServletRequest#setAttribute(String, Object)}.
177: *
178: * @since 1.1
179: */
180: public void setAttribute(String name, Object object);
181:
182: /**
183: * See {@link HttpServletRequest#getCharacterEncoding()}.
184: *
185: * @since 1.1
186: */
187: public String getCharacterEncoding();
188:
189: /**
190: * See {@link HttpServletRequest#getContentType()}.
191: *
192: * @since 1.1
193: */
194: public String getContentType();
195:
196: /**
197: * See {@link HttpServletRequest#getDateHeader(String)}.
198: *
199: * @since 1.1
200: */
201: public long getDateHeader(String name);
202:
203: /**
204: * See {@link HttpServletRequest#getHeader(String)}.
205: *
206: * @since 1.1
207: */
208: public String getHeader(String name);
209:
210: /**
211: * See {@link HttpServletRequest#getHeaderNames()}.
212: *
213: * @since 1.1
214: */
215: public Enumeration getHeaderNames();
216:
217: /**
218: * See {@link HttpServletRequest#getHeaders(String)}.
219: *
220: * @since 1.1
221: */
222: public Enumeration getHeaders(String name);
223:
224: /**
225: * See {@link HttpServletRequest#getIntHeader(String)}.
226: *
227: * @since 1.1
228: */
229: public int getIntHeader(String name);
230:
231: /**
232: * See {@link HttpServletRequest#getLocale()}.
233: *
234: * @since 1.1
235: */
236: public Locale getLocale();
237:
238: /**
239: * See {@link HttpServletRequest#getLocales()}.
240: *
241: * @since 1.1
242: */
243: public Enumeration getLocales();
244:
245: /**
246: * See {@link HttpServletRequest#getProtocol()}.
247: *
248: * @since 1.1
249: */
250: public String getProtocol();
251:
252: /**
253: * See {@link HttpServletRequest#getRemoteAddr()}.
254: *
255: * @since 1.1
256: */
257: public String getRemoteAddr();
258:
259: /**
260: * See {@link HttpServletRequest#getRemoteUser()}.
261: *
262: * @since 1.1
263: */
264: public String getRemoteUser();
265:
266: /**
267: * See {@link HttpServletRequest#getRemoteHost()}.
268: *
269: * @since 1.1
270: */
271: public String getRemoteHost();
272:
273: /**
274: * See {@link HttpServletRequest#getRequestDispatcher(String)}.
275: *
276: * @since 1.1
277: */
278: public RequestDispatcher getRequestDispatcher(String url);
279:
280: /**
281: * See {@link HttpServletRequest#getSession()}.
282: *
283: * @since 1.1
284: */
285: public HttpSession getSession();
286:
287: /**
288: * See {@link HttpServletRequest#getSession(boolean)}.
289: *
290: * @since 1.1
291: */
292: public HttpSession getSession(boolean create);
293:
294: /**
295: * See {@link HttpServletRequest#getServerPort()}.
296: *
297: * @since 1.1
298: */
299: public int getServerPort();
300:
301: /**
302: * See {@link HttpServletRequest#getScheme()}.
303: *
304: * @since 1.1
305: */
306: public String getScheme();
307:
308: /**
309: * See {@link HttpServletRequest#getServerName()}.
310: *
311: * @since 1.1
312: */
313: public String getServerName();
314:
315: /**
316: * See {@link HttpServletRequest#getContextPath()}.
317: *
318: * @since 1.1
319: */
320: public String getContextPath();
321:
322: /**
323: * See {@link HttpServletRequest#isSecure()}.
324: *
325: * @since 1.1
326: */
327: public boolean isSecure();
328:
329: /**
330: * Retrieves the underlying {@link HttpServletRequest}.
331: *
332: * @return the underlying <code>HttpServletRequest</code> instance; or
333: * <p><code>null</code> if this request isn't backed by
334: * <code>HttpServletRequest</code>
335: * @since 1.1
336: */
337: public HttpServletRequest getHttpServletRequest();
338: }
|