1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Serializable;
import javax.portlet.MimeResponse;
import javax.portlet.PortletResponse;
import javax.portlet.ResourceResponse;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
/**
* A generic response from the server, wrapping a more specific response type,
* e.g. HttpServletResponse or PortletResponse.
*
* @since 7.0
*/
public interface WrappedResponse extends Serializable {
/**
* Sets the (http) status code for the response. If you want to include an
* error message along the status code, use {@link #sendError(int, String)}
* instead.
*
* @param statusCode
* the status code to set
* @see HttpServletResponse#setStatus(int)
*
* @see ResourceResponse#HTTP_STATUS_CODE
*/
public void setStatus(int statusCode);
/**
* Sets the content type of this response. If the content type including a
* charset is set before {@link #getWriter()} is invoked, the returned
* PrintWriter will automatically use the defined charset.
*
* @param contentType
* a string specifying the MIME type of the content
*
* @see ServletResponse#setContentType(String)
* @see MimeResponse#setContentType(String)
*/
public void setContentType(String contentType);
/**
* Sets the value of a generic response header. If the header had already
* been set, the new value overwrites the previous one.
*
* @param name
* the name of the header
* @param value
* the header value.
*
* @see HttpServletResponse#setHeader(String, String)
* @see PortletResponse#setProperty(String, String)
*/
public void setHeader(String name, String value);
/**
* Properly formats a timestamp as a date header. If the header had already
* been set, the new value overwrites the previous one.
*
* @param name
* the name of the header
* @param timestamp
* the number of milliseconds since epoch
*
* @see HttpServletResponse#setDateHeader(String, long)
*/
public void setDateHeader(String name, long timestamp);
/**
* Returns a <code>OutputStream</code> for writing binary data in the
* response.
* <p>
* Either this method or getWriter() may be called to write the response,
* not both.
*
* @return a <code>OutputStream</code> for writing binary data
* @throws IOException
* if an input or output exception occurred
*
* @see #getWriter()
* @see ServletResponse#getOutputStream()
* @see MimeResponse#getPortletOutputStream()
*/
public OutputStream getOutputStream() throws IOException;
/**
* Returns a <code>PrintWriter</code> object that can send character text to
* the client. The PrintWriter uses the character encoding defined using
* setContentType.
* <p>
* Either this method or getOutputStream() may be called to write the
* response, not both.
*
* @return a <code>PrintWriter</code> for writing character text
* @throws IOException
* if an input or output exception occurred
*
* @see #getOutputStream()
* @see ServletResponse#getWriter()
* @see MimeResponse#getWriter()
*/
public PrintWriter getWriter() throws IOException;
/**
* Sets cache time in milliseconds, -1 means no cache at all. All required
* headers related to caching in the response are set based on the time.
*
* @param milliseconds
* Cache time in milliseconds
*/
public void setCacheTime(long milliseconds);
/**
* Sends an error response to the client using the specified status code and
* clears the buffer. In some configurations, this can cause a predefined
* error page to be displayed.
*
* @param errorCode
* the HTTP status code
* @param message
* a message to accompany the error
* @throws IOException
* if an input or output exception occurs
*
* @see HttpServletResponse#sendError(int, String)
*/
public void sendError(int errorCode, String message) throws IOException;
/**
* Gets the deployment configuration for the context of this response.
*
* @return the deployment configuration
*
* @see DeploymentConfiguration
*/
public DeploymentConfiguration getDeploymentConfiguration();
}
|