KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > core > I_CmsResponse


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/core/I_CmsResponse.java,v $
3 * Date : $Date: 2005/06/27 23:22:30 $
4 * Version: $Revision: 1.2 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.core;
30
31 import java.io.IOException JavaDoc;
32 import java.io.OutputStream JavaDoc;
33
34 import javax.servlet.http.HttpServletResponse JavaDoc;
35
36 /**
37  * This interface defines an OpenCms response, a generic response object that
38  * is used by OpenCms and provides methods to send processed data back to
39  * the requesting user.<p>
40  *
41  * Implementations of this interface use an existing response
42  * (e.g. HttpServletResponse) to initialize an I_CmsResponse.
43  *
44  * @author Michael Emmerich
45  * @author Alexander Kandzior
46  *
47  * @version $Revision: 1.2 $ $Date: 2005/06/27 23:22:30 $
48  *
49  * @deprecated Will not be supported past the OpenCms 6 release.
50  */

51 public interface I_CmsResponse {
52
53     /** Request context attribute name. */
54     String JavaDoc C_CMS_RESPONSE = "__I_CmsResponse";
55     
56     /**
57      * Returns the original response that was used to create the CmsResponse.
58      *
59      * @return The original response of the CmsResponse.
60      */

61     HttpServletResponse JavaDoc getOriginalResponse();
62     
63     /**
64      * Returns the type of the response that was used to create the CmsResponse.
65      * The returned int must be one of the constants defined above in this interface.
66      *
67      * @return The type of the CmsResponse.
68      */

69     int getOriginalResponseType();
70     
71     /**
72      * Returns an OutputStream for writing the response data.
73      *
74      * @return OutputStream for writing data.
75      * @throws IOException if something goes wrong
76      */

77     OutputStream JavaDoc getOutputStream() throws IOException JavaDoc;
78     
79     /**
80      * Check if the output stream was requested previously.
81      * @return <code>true</code> if getOutputStream() was called, <code>false</code> otherwise.
82      */

83     boolean isOutputWritten();
84     
85     /**
86      * Check if the current request was redirected. In this case, the
87      * servlet must not write any bytes to the output stream.
88      * @return <code>true</code> if the request is redirected, <code>false</code> otherwise.
89      */

90     boolean isRedirected();
91     
92     /**
93      * Sets a redirect to send the response to.<p>
94      *
95      * @param location the location the response is redirected to
96      * @throws IOException if something goes wrong
97      */

98     void sendCmsRedirect(String JavaDoc location) throws IOException JavaDoc;
99     
100     /**
101      * Sets the error code that is returnd by the response. The error code is specified
102      * by a numeric value.
103      *
104      * @param code The error code to be set.
105      * @throws IOException if something goes wrong
106      */

107     void sendError(int code) throws IOException JavaDoc;
108     
109     /**
110      * Sets the error code and a additional message that is returnd by the response.
111      * The error code is specified by a numeric value.
112      *
113      * @param code The error code to be set.
114      * @param msg Additional error message.
115      * @throws IOException if something goes wrong
116      */

117     void sendError(int code, String JavaDoc msg) throws IOException JavaDoc;
118     
119     /**
120      * Helper function for a redirect to the cluster url.
121      *
122      * @param location a complete url, eg. <code>http://servername/servlets/opencms/index.html</code>
123      * @throws IOException if something goes wrong
124      */

125     void sendRedirect(String JavaDoc location) throws IOException JavaDoc;
126     
127     /**
128      * Sets the length of the content being returned by the server.
129      *
130      * @param len Number of bytes to be returned by the response.
131      */

132     void setContentLength(int len);
133     
134     /**
135      * Sets the content type of the response to the specified type.
136      *
137      * @param type The contnent type of the response.
138      */

139     void setContentType(String JavaDoc type);
140     
141     /**
142      * Returns the content type of the response which has previously
143      * been set using {@link #setContentType(String)}.
144      *
145      * @return the content type of the response.
146      */

147     String JavaDoc getContentType();
148         
149     /**
150      * Sets a header-field in the response.
151      *
152      * @param key The key for the header.
153      * @param value The value for the header.
154      */

155     void setHeader(String JavaDoc key, String JavaDoc value);
156
157     /**
158      * Add a header-field in the response.
159      *
160      * @param key The key for the header.
161      * @param value The value for the header.
162      */

163     void addHeader(String JavaDoc key, String JavaDoc value);
164     
165     /**
166      * Sets the last modified header-field in the response.
167      *
168      * @param time The last-modified time.
169      */

170     void setLastModified(long time);
171     
172     /**
173      * Checks, if the header was set already.
174      * @param key the header-key to check.
175      * @return true if the header was set before else false.
176      */

177     boolean containsHeader(String JavaDoc key);
178 }
179
Popular Tags