KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jforum > util > legacy > commons > fileupload > servlet > ServletRequestContext


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.io.InputStream JavaDoc;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
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 JavaDoc request;
43
44
45     // ----------------------------------------------------------- Constructors
46

47     /**
48      * Construct a context for this request.
49      *
50      * @param request The request to which this context applies.
51      */

52     public ServletRequestContext(HttpServletRequest JavaDoc request) {
53         this.request = request;
54     }
55
56
57     // --------------------------------------------------------- Public Methods
58

59     /**
60      * Retrieve the content type of the request.
61      *
62      * @return The content type of the request.
63      */

64     public String JavaDoc getContentType() {
65         return request.getContentType();
66     }
67
68     /**
69      * Retrieve the content length of the request.
70      *
71      * @return The content length of the request.
72      */

73     public int getContentLength() {
74         return request.getContentLength();
75     }
76
77     /**
78      * Retrieve the input stream for the request.
79      *
80      * @return The input stream for the request.
81      *
82      * @throws IOException if a problem occurs.
83      */

84     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
85         return request.getInputStream();
86     }
87     
88     public String JavaDoc toString() {
89         return "ContentLength="
90             + this.getContentLength()
91             + ", ContentType="
92             + this.getContentType();
93     }
94 }
95
Popular Tags