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