|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
WebResponse.java | - | - | - | - |
|
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.web; | |
16 | ||
17 | import java.io.IOException; | |
18 | import java.io.OutputStream; | |
19 | import java.io.PrintWriter; | |
20 | ||
21 | import org.apache.tapestry.util.ContentType; | |
22 | ||
23 | /** | |
24 | * Controls the response to the client, and specifically allows for creating the output stream (or | |
25 | * print writer) to which content is sent. This is essentially a generic version of | |
26 | * {@link javax.servlet.http.HttpServletResponse}. Some operations may be unsupported in some | |
27 | * implementations (for example, the portlet implementation can't handle any of the setHeader | |
28 | * methods). | |
29 | * | |
30 | * @author Howard M. Lewis Ship | |
31 | * @since 4.0 | |
32 | */ | |
33 | public interface WebResponse | |
34 | { | |
35 | /** | |
36 | * Returns a output stream to which output should be sent. This method should only be invoked | |
37 | * once on a response. | |
38 | * | |
39 | * @return the output stream, configured for the given type. | |
40 | */ | |
41 | ||
42 | public OutputStream getOutputStream(ContentType contentType) throws IOException; | |
43 | ||
44 | /** | |
45 | * Returns a {@link PrintWriter} to which output should be sent. This method should be invoked | |
46 | * once on a response. A second call is expected to be so that an exception page can be | |
47 | * rendered, and the underlying request data is reset. | |
48 | */ | |
49 | ||
50 | public PrintWriter getPrintWriter(ContentType contentType) throws IOException; | |
51 | ||
52 | /** | |
53 | * Encodes a URL, which adds information to the URL needed to ensure that the request triggered | |
54 | * by the URL will be associated with the current session (if any). In most cases, the string is | |
55 | * returned unchanged. | |
56 | */ | |
57 | ||
58 | public String encodeURL(String url); | |
59 | ||
60 | /** | |
61 | * Resets any buffered content. This may be used after an error to radically change what the | |
62 | * output will be. | |
63 | */ | |
64 | ||
65 | public void reset(); | |
66 | ||
67 | public void setContentLength(int contentLength); | |
68 | ||
69 | /** | |
70 | * Returns a value to be prefixed or suffixed with any client-side JavaScript elements | |
71 | * (variables and function names) to ensure that they are unique with the context of the entire | |
72 | * page. For servlets, this is the empty string. | |
73 | */ | |
74 | ||
75 | public String getNamespace(); | |
76 | ||
77 | /** | |
78 | * Sets a response header as a date. | |
79 | * | |
80 | * @param name | |
81 | * the name of the header to set | |
82 | * @param date | |
83 | * the date value to set, in milliseconds since the epoch | |
84 | */ | |
85 | public void setDateHeader(String name, long date); | |
86 | ||
87 | /** | |
88 | * Sets a response header as a string. | |
89 | * | |
90 | * @param name | |
91 | * the name of the header to set | |
92 | * @param value | |
93 | * the value for the named header | |
94 | */ | |
95 | ||
96 | public void setHeader(String name, String value); | |
97 | ||
98 | /** | |
99 | * Sets a response header with the given name and integer value. | |
100 | * | |
101 | * @param name | |
102 | * the name of the header to set | |
103 | * @param value | |
104 | * the value for the named header | |
105 | */ | |
106 | public void setIntHeader(String name, int value); | |
107 | ||
108 | /** | |
109 | * Sets the status code for this response. | |
110 | */ | |
111 | public void setStatus(int status); | |
112 | } |
|