Source Code Cross Referenced for XINSServletResponse.java in  » Web-Services » xins » org » xins » common » servlet » container » 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 » Web Services » xins » org.xins.common.servlet.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: XINSServletResponse.java,v 1.22 2007/09/18 08:45:08 agoubard Exp $
003:         *
004:         * Copyright 2003-2007 Orange Nederland Breedband B.V.
005:         * See the COPYRIGHT file for redistribution and use restrictions.
006:         */
007:        package org.xins.common.servlet.container;
008:
009:        import java.io.PrintWriter;
010:        import java.io.StringWriter;
011:        import java.util.Locale;
012:        import javax.servlet.ServletOutputStream;
013:        import javax.servlet.http.Cookie;
014:        import javax.servlet.http.HttpServletResponse;
015:        import org.xins.common.MandatoryArgumentChecker;
016:        import org.xins.common.collections.BasicPropertyReader;
017:        import org.xins.common.collections.PropertyReader;
018:
019:        /**
020:         * This class is an implementation of the HttpServletResponse that can be
021:         * invoked locally.
022:         *
023:         * @version $Revision: 1.22 $ $Date: 2007/09/18 08:45:08 $
024:         * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
025:         */
026:        public class XINSServletResponse implements  HttpServletResponse {
027:
028:            /**
029:             * The content type of the result. Initially <code>null</code>.
030:             */
031:            private String _contentType;
032:
033:            /**
034:             * The non-negative content length, or a negative number if unset.
035:             * Initially a negative number.
036:             */
037:            private int _contentLength = -99;
038:
039:            /**
040:             * The status of the result.
041:             */
042:            private int _status;
043:
044:            /**
045:             * The encoding of the result. Must default to ISO-8859-1, according to the
046:             * Java Servlet 2.4 Specification.
047:             */
048:            private String _encoding = "ISO-8859-1";
049:
050:            /**
051:             * The writer where to write the result.
052:             */
053:            private StringWriter _writer;
054:
055:            /**
056:             * The headers.
057:             */
058:            private BasicPropertyReader _headers = new BasicPropertyReader();
059:
060:            /**
061:             * Creates a new instance of <code>XINSServletResponse</code>.
062:             */
063:            public XINSServletResponse() {
064:            }
065:
066:            public void addDateHeader(String str, long param) {
067:                throw new UnsupportedOperationException();
068:            }
069:
070:            public void setDateHeader(String str, long param) {
071:                throw new UnsupportedOperationException();
072:            }
073:
074:            public String encodeUrl(String url) {
075:                return url;
076:            }
077:
078:            public String encodeURL(String url) {
079:                return url;
080:            }
081:
082:            public String encodeRedirectUrl(String str) {
083:                throw new UnsupportedOperationException();
084:            }
085:
086:            public String encodeRedirectURL(String str) {
087:                throw new UnsupportedOperationException();
088:            }
089:
090:            public boolean containsHeader(String str) {
091:                return _headers.get(str) != null;
092:            }
093:
094:            public void sendRedirect(String location) {
095:                setStatus(302);
096:                setHeader("Location", location);
097:            }
098:
099:            /**
100:             * Sets the content type.
101:             *
102:             * @param type
103:             *    the content type, cannot be <code>null</code>.
104:             *
105:             * @throws IllegalArgumentException
106:             *    if <code>type == null</code>.
107:             */
108:            public void setContentType(String type)
109:                    throws IllegalArgumentException {
110:
111:                MandatoryArgumentChecker.check("type", type);
112:
113:                setHeader("Content-Type", type);
114:
115:                String search = "charset=";
116:                int i = type.indexOf(search);
117:                if (i >= 0) {
118:                    _encoding = type.substring(i + search.length());
119:                }
120:
121:                _contentType = type;
122:            }
123:
124:            public void setStatus(int sc) {
125:                _status = sc;
126:            }
127:
128:            public void sendError(int sc) {
129:                sendError(sc, null);
130:            }
131:
132:            public void setBufferSize(int param) {
133:                throw new UnsupportedOperationException();
134:            }
135:
136:            /**
137:             * Returns the content length.
138:             *
139:             * @return
140:             *    the (non-negative) content length if set, or a negative value if
141:             *    unset.
142:             */
143:            int getContentLength() {
144:                return _contentLength;
145:            }
146:
147:            public void setContentLength(int param) {
148:                _contentLength = param;
149:                setIntHeader("Content-Length", param);
150:            }
151:
152:            public void addCookie(Cookie cookie) {
153:                String cookieHeader = cookie.getName() + "="
154:                        + cookie.getValue();
155:                if (cookie.getPath() != null) {
156:                    cookieHeader += "; path=" + cookie.getPath();
157:                }
158:                if (cookie.getDomain() != null) {
159:                    cookieHeader += "; domain=" + cookie.getDomain();
160:                }
161:                setHeader("Set-Cookie", cookieHeader);
162:            }
163:
164:            public void setLocale(Locale locale) {
165:                throw new UnsupportedOperationException();
166:            }
167:
168:            public void setStatus(int param, String str) {
169:                throw new UnsupportedOperationException();
170:            }
171:
172:            public void setIntHeader(String str, int param) {
173:                setHeader(str, "" + param);
174:            }
175:
176:            public void addIntHeader(String str, int param) {
177:                setHeader(str, "" + param);
178:            }
179:
180:            public void sendError(int sc, String msg) {
181:                _status = sc;
182:            }
183:
184:            public void setHeader(String str, String str1) {
185:                _headers.set(str, str1);
186:            }
187:
188:            public Locale getLocale() {
189:                throw new UnsupportedOperationException();
190:            }
191:
192:            public String getCharacterEncoding() {
193:                return _encoding;
194:            }
195:
196:            public int getBufferSize() {
197:                throw new UnsupportedOperationException();
198:            }
199:
200:            public void flushBuffer() {
201:                throw new UnsupportedOperationException();
202:            }
203:
204:            public void addHeader(String str, String str1) {
205:                _headers.set(str, str1);
206:            }
207:
208:            public ServletOutputStream getOutputStream() {
209:                throw new UnsupportedOperationException();
210:            }
211:
212:            public PrintWriter getWriter() {
213:                _writer = new StringWriter();
214:                return new PrintWriter(_writer);
215:            }
216:
217:            public boolean isCommitted() {
218:                throw new UnsupportedOperationException();
219:            }
220:
221:            public void reset() {
222:                throw new UnsupportedOperationException();
223:            }
224:
225:            public void resetBuffer() {
226:                throw new UnsupportedOperationException();
227:            }
228:
229:            /**
230:             * Gets the returned message from the servlet.
231:             *
232:             * @return
233:             *    the returned message or <code>null</code> if no message is returned.
234:             */
235:            public String getResult() {
236:                if (_writer == null) {
237:                    return null;
238:                }
239:                return _writer.toString();
240:            }
241:
242:            /**
243:             * Gets the status of the returned message.
244:             *
245:             * @return
246:             *    the HTTP status returned.
247:             */
248:            public int getStatus() {
249:                return _status;
250:            }
251:
252:            /**
253:             * Gets the type of the returned content.
254:             *
255:             * @return
256:             *    the content type, can be <code>null</code>.
257:             *
258:             * @see #setContentType(String)
259:             */
260:            public String getContentType() {
261:                return _contentType;
262:            }
263:
264:            /**
265:             * Gets the headers to return to the client.
266:             *
267:             * @return
268:             *    the headers, cannot be <code>null</code>.
269:             *
270:             * @since XINS 1.3.0
271:             */
272:            public PropertyReader getHeaders() {
273:                return _headers;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.