Source Code Cross Referenced for Response.java in  » J2EE » wicket » wicket » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » wicket » wicket 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: Response.java 462116 2006-09-08 22:41:11Z ehillenius $ $Revision:
003:         * 1.6 $ $Date: 2006-09-09 00:41:11 +0200 (Sat, 09 Sep 2006) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket;
019:
020:        import java.io.OutputStream;
021:        import java.util.List;
022:        import java.util.Locale;
023:
024:        import wicket.markup.ComponentTag;
025:        import wicket.util.string.AppendingStringBuffer;
026:        import wicket.util.string.Strings;
027:        import wicket.util.time.Time;
028:
029:        /**
030:         * Abstract base class for different implementations of response writing. A
031:         * subclass must implement write(String) to write a String to the response
032:         * destination (whether it be a browser, a file, a test harness or some other
033:         * place). A subclass may optionally implement close(), encodeURL(String),
034:         * redirect(String), isRedirect() or setContentType(String) as appropriate.
035:         * 
036:         * @author Jonathan Locke
037:         */
038:        public abstract class Response {
039:            /** Default encoding of output stream */
040:            private String defaultEncoding;
041:
042:            /**
043:             * Closes the response output stream
044:             */
045:            public void close() {
046:            }
047:
048:            /**
049:             * Called when the Response needs to reset itself.
050:             * Subclasses can empty there buffer or build up state.
051:             */
052:            public void reset() {
053:
054:            }
055:
056:            /**
057:             * An implementation of this method is only required if a subclass wishes to
058:             * support sessions via URL rewriting. This default implementation simply
059:             * returns the URL String it is passed.
060:             * 
061:             * @param url
062:             *            The URL to encode
063:             * @return The encoded url
064:             */
065:            public CharSequence encodeURL(final CharSequence url) {
066:                return url;
067:            }
068:
069:            /**
070:             * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
071:             * 
072:             * Loops over all the response filters that were set (if any) with the give
073:             * response returns the response buffer itself if there where now filters or
074:             * the response buffer that was created/returned by the filter(s)
075:             * 
076:             * @param responseBuffer
077:             *            The response buffer to be filtered
078:             * @return Returns the filtered string buffer.
079:             */
080:            public final AppendingStringBuffer filter(
081:                    AppendingStringBuffer responseBuffer) {
082:                List responseFilters = Application.get()
083:                        .getRequestCycleSettings().getResponseFilters();
084:                if (responseFilters == null) {
085:                    return responseBuffer;
086:                }
087:                for (int i = 0; i < responseFilters.size(); i++) {
088:                    IResponseFilter filter = (IResponseFilter) responseFilters
089:                            .get(i);
090:                    responseBuffer = filter.filter(responseBuffer);
091:                }
092:                return responseBuffer;
093:            }
094:
095:            /**
096:             * Get the default encoding
097:             * 
098:             * @return default encoding
099:             */
100:            public String getCharacterEncoding() {
101:                if (this .defaultEncoding == null) {
102:                    return Application.get().getRequestCycleSettings()
103:                            .getResponseRequestEncoding();
104:                } else {
105:                    return this .defaultEncoding;
106:                }
107:            }
108:
109:            /**
110:             * @return The output stream for this response
111:             */
112:            public abstract OutputStream getOutputStream();
113:
114:            /**
115:             * Returns true if a redirection has occurred. The default implementation
116:             * always returns false since redirect is not implemented by default.
117:             * 
118:             * @return True if the redirect method has been called, making this response
119:             *         a redirect.
120:             */
121:            public boolean isRedirect() {
122:                return false;
123:            }
124:
125:            /**
126:             * CLIENTS SHOULD NEVER CALL THIS METHOD FOR DAY TO DAY USE!
127:             * <p>
128:             * A subclass may override this method to implement redirection. Subclasses
129:             * which have no need to do redirection may choose not to override this
130:             * default implementation, which does nothing. For example, if a subclass
131:             * wishes to write output to a file or is part of a testing harness, there
132:             * may be no meaning to redirection.
133:             * </p>
134:             * 
135:             * @param url
136:             *            The URL to redirect to
137:             */
138:            public void redirect(final String url) {
139:            }
140:
141:            /**
142:             * Set the default encoding for the output. 
143:             * Note: It is up to the derived class to make use of the information.
144:             * Class Respsonse simply stores the value, but does not apply
145:             * it anywhere automatically.
146:             * 
147:             * @param encoding
148:             */
149:            public void setCharacterEncoding(final String encoding) {
150:                this .defaultEncoding = encoding;
151:            }
152:
153:            /**
154:             * Set the content length on the response, if appropriate in the subclass.
155:             * This default implementation does nothing.
156:             * 
157:             * @param length
158:             *            The length of the content
159:             */
160:            public void setContentLength(final long length) {
161:            }
162:
163:            /**
164:             * Set the content type on the response, if appropriate in the subclass.
165:             * This default implementation does nothing.
166:             * 
167:             * @param mimeType
168:             *            The mime type
169:             */
170:            public void setContentType(final String mimeType) {
171:            }
172:
173:            /**
174:             * Set the contents last modified time, if appropriate in the subclass.
175:             * This default implementation does nothing.
176:             * @param time 
177:             *				The time object 
178:             */
179:            public void setLastModifiedTime(Time time) {
180:            }
181:
182:            /**
183:             * @param locale
184:             *            Locale to use for this response
185:             */
186:            public void setLocale(final Locale locale) {
187:            }
188:
189:            /**
190:             * Writes the given tag to via the write(String) abstract method.
191:             * 
192:             * @param tag
193:             *            The tag to write
194:             */
195:            public final void write(final ComponentTag tag) {
196:                write(tag.toString());
197:            }
198:
199:            /**
200:             * Writes the given string to the Response subclass output destination.
201:             * 
202:             * @param string
203:             *            The string to write
204:             */
205:            public abstract void write(final CharSequence string);
206:
207:            /**
208:             * Writes the given string to the Response subclass output destination and
209:             * appends a cr/nl depending on the OS
210:             * 
211:             * @param string
212:             */
213:            public final void println(final CharSequence string) {
214:                write(string);
215:                write(Strings.LINE_SEPARATOR);
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.