01: /*
02: * Copyright 2001-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package net.jforum.util.legacy.commons.fileupload.servlet;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20:
21: import javax.servlet.http.HttpServletRequest;
22:
23: import net.jforum.util.legacy.commons.fileupload.RequestContext;
24:
25: /**
26: * <p>Provides access to the request information needed for a request made to
27: * an HTTP servlet.</p>
28: *
29: * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
30: *
31: * @since FileUpload 1.1
32: *
33: * @version $Id: ServletRequestContext.java,v 1.3 2005/07/26 03:06:04 rafaelsteil Exp $
34: */
35: public class ServletRequestContext implements RequestContext {
36:
37: // ----------------------------------------------------- Instance Variables
38:
39: /**
40: * The request for which the context is being provided.
41: */
42: private HttpServletRequest request;
43:
44: // ----------------------------------------------------------- Constructors
45:
46: /**
47: * Construct a context for this request.
48: *
49: * @param request The request to which this context applies.
50: */
51: public ServletRequestContext(HttpServletRequest request) {
52: this .request = request;
53: }
54:
55: // --------------------------------------------------------- Public Methods
56:
57: /**
58: * Retrieve the content type of the request.
59: *
60: * @return The content type of the request.
61: */
62: public String getContentType() {
63: return request.getContentType();
64: }
65:
66: /**
67: * Retrieve the content length of the request.
68: *
69: * @return The content length of the request.
70: */
71: public int getContentLength() {
72: return request.getContentLength();
73: }
74:
75: /**
76: * Retrieve the input stream for the request.
77: *
78: * @return The input stream for the request.
79: *
80: * @throws IOException if a problem occurs.
81: */
82: public InputStream getInputStream() throws IOException {
83: return request.getInputStream();
84: }
85:
86: public String toString() {
87: return "ContentLength=" + this .getContentLength()
88: + ", ContentType=" + this.getContentType();
89: }
90: }
|