KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > myvietnam > mvncore > web > fileupload > servlet > ServletRequestContext


1 /*
2  * Copyright 2001-2005 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.myvietnam.mvncore.web.fileupload.servlet;
17
18 import java.io.InputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import net.myvietnam.mvncore.web.fileupload.RequestContext;
22
23 /**
24  * <p>Provides access to the request information needed for a request made to
25  * an HTTP servlet.</p>
26  *
27  * @author <a HREF="mailto:martinc@apache.org">Martin Cooper</a>
28  *
29  * @since FileUpload 1.1
30  *
31  * @version $Id: ServletRequestContext.java,v 1.2 2006/02/12 04:43:11 minhnn Exp $
32  */

33 public class ServletRequestContext implements RequestContext {
34
35     // ----------------------------------------------------- Instance Variables
36

37     /**
38      * The request for which the context is being provided.
39      */

40     private HttpServletRequest JavaDoc request;
41
42
43     // ----------------------------------------------------------- Constructors
44

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

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

57     /**
58      * Retrieve the character encoding for the request.
59      *
60      * @return The character encoding for the request.
61      */

62     public String JavaDoc getCharacterEncoding() {
63         return request.getCharacterEncoding();
64     }
65
66     /**
67      * Retrieve the content type of the request.
68      *
69      * @return The content type of the request.
70      */

71     public String JavaDoc getContentType() {
72         return request.getContentType();
73     }
74
75     /**
76      * Retrieve the content length of the request.
77      *
78      * @return The content length of the request.
79      */

80     public int getContentLength() {
81         return request.getContentLength();
82     }
83
84     /**
85      * Retrieve the input stream for the request.
86      *
87      * @return The input stream for the request.
88      *
89      * @throws IOException if a problem occurs.
90      */

91     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
92         return request.getInputStream();
93     }
94
95     /**
96      * Returns a string representation of this object.
97      *
98      * @return a string representation of this object.
99      */

100     public String JavaDoc toString() {
101         return "ContentLength="
102             + this.getContentLength()
103             + ", ContentType="
104             + this.getContentType();
105     }
106 }
107
Popular Tags