Source Code Cross Referenced for Response.java in  » Web-Services » restlet-1.0.8 » org » restlet » data » 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 » restlet 1.0.8 » org.restlet.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 Noelios Consulting.
003:         * 
004:         * The contents of this file are subject to the terms of the Common Development
005:         * and Distribution License (the "License"). You may not use this file except in
006:         * compliance with the License.
007:         * 
008:         * You can obtain a copy of the license at
009:         * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010:         * language governing permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL HEADER in each file and
013:         * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014:         * applicable, add the following below this CDDL HEADER, with the fields
015:         * enclosed by brackets "[]" replaced with your own identifying information:
016:         * Portions Copyright [yyyy] [name of copyright owner]
017:         */
018:
019:        package org.restlet.data;
020:
021:        import java.util.EnumSet;
022:        import java.util.HashSet;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import org.restlet.util.Series;
027:
028:        /**
029:         * Generic response sent by server connectors. It is then received by client
030:         * connectors. Responses are uniform across all types of connectors, protocols
031:         * and components.
032:         * 
033:         * @see org.restlet.data.Request
034:         * @see org.restlet.Uniform
035:         * @author Jerome Louvel (contact@noelios.com)
036:         */
037:        public class Response extends Message {
038:            /** The set of methods allowed on the requested resource. */
039:            private Set<Method> allowedMethods;
040:
041:            /** The authentication request sent by an origin server to a client. */
042:            private ChallengeRequest challengeRequest;
043:
044:            /** The cookie settings provided by the server. */
045:            private Series<CookieSetting> cookieSettings;
046:
047:            /** The set of dimensions on which the response entity may vary. */
048:            private Set<Dimension> dimensions;
049:
050:            /** The redirection reference. */
051:            private Reference redirectRef;
052:
053:            /** The associated request. */
054:            private Request request;
055:
056:            /** The server-specific information. */
057:            private ServerInfo serverInfo;
058:
059:            /** The status. */
060:            private Status status;
061:
062:            /**
063:             * Constructor.
064:             * 
065:             * @param request
066:             *            The request associated to this response.
067:             */
068:            public Response(Request request) {
069:                this .allowedMethods = null;
070:                this .challengeRequest = null;
071:                this .cookieSettings = null;
072:                this .dimensions = null;
073:                this .redirectRef = null;
074:                this .request = request;
075:                this .serverInfo = null;
076:                this .status = Status.SUCCESS_OK;
077:            }
078:
079:            /**
080:             * Returns the set of methods allowed on the requested resource. This
081:             * property only has to be updated when a status
082:             * CLIENT_ERROR_METHOD_NOT_ALLOWED is set.
083:             * 
084:             * @return The list of allowed methods.
085:             */
086:            public Set<Method> getAllowedMethods() {
087:                if (this .allowedMethods == null)
088:                    this .allowedMethods = new HashSet<Method>();
089:                return this .allowedMethods;
090:            }
091:
092:            /**
093:             * Returns the authentication request sent by an origin server to a client.
094:             * 
095:             * @return The authentication request sent by an origin server to a client.
096:             */
097:            public ChallengeRequest getChallengeRequest() {
098:                return this .challengeRequest;
099:            }
100:
101:            /**
102:             * Returns the cookie settings provided by the server.
103:             * 
104:             * @return The cookie settings provided by the server.
105:             */
106:            public Series<CookieSetting> getCookieSettings() {
107:                if (this .cookieSettings == null)
108:                    this .cookieSettings = new CookieSettingSeries();
109:                return this .cookieSettings;
110:            }
111:
112:            /**
113:             * Returns the set of selecting dimensions on which the response entity may
114:             * vary. If some server-side content negotiation is done, this set should be
115:             * properly updated, other it can be left empty.
116:             * 
117:             * @return The set of dimensions on which the response entity may vary.
118:             */
119:            public Set<Dimension> getDimensions() {
120:                if (this .dimensions == null)
121:                    this .dimensions = EnumSet.noneOf(Dimension.class);
122:                return this .dimensions;
123:            }
124:
125:            /**
126:             * Returns the reference that the client should follow for redirections or
127:             * resource creations.
128:             * 
129:             * @return The redirection reference.
130:             */
131:            public Reference getRedirectRef() {
132:                return this .redirectRef;
133:            }
134:
135:            /**
136:             * Returns the associated request
137:             * 
138:             * @return The associated request
139:             */
140:            public Request getRequest() {
141:                return request;
142:            }
143:
144:            /**
145:             * Returns the server-specific information.
146:             * 
147:             * @return The server-specific information.
148:             */
149:            public ServerInfo getServerInfo() {
150:                if (this .serverInfo == null)
151:                    this .serverInfo = new ServerInfo();
152:                return this .serverInfo;
153:            }
154:
155:            /**
156:             * Returns the status.
157:             * 
158:             * @return The status.
159:             */
160:            public Status getStatus() {
161:                return this .status;
162:            }
163:
164:            /**
165:             * Permanently redirects the client to a target URI. The client is expected
166:             * to reuse the same method for the new request.
167:             * 
168:             * @param targetUri
169:             *            The target URI.
170:             */
171:            public void redirectPermanent(String targetUri) {
172:                redirectPermanent(new Reference(targetUri));
173:            }
174:
175:            /**
176:             * Permanently redirects the client to a target URI. The client is expected
177:             * to reuse the same method for the new request.
178:             * 
179:             * @param targetRef
180:             *            The target URI reference.
181:             */
182:            public void redirectPermanent(Reference targetRef) {
183:                setRedirectRef(targetRef);
184:                setStatus(Status.REDIRECTION_PERMANENT);
185:            }
186:
187:            /**
188:             * Redirects the client to a different URI that SHOULD be retrieved using a
189:             * GET method on that resource. This method exists primarily to allow the
190:             * output of a POST-activated script to redirect the user agent to a
191:             * selected resource. The new URI is not a substitute reference for the
192:             * originally requested resource.
193:             * 
194:             * @param targetUri
195:             *            The target URI.
196:             */
197:            public void redirectSeeOther(String targetUri) {
198:                redirectSeeOther(new Reference(targetUri));
199:            }
200:
201:            /**
202:             * Redirects the client to a different URI that SHOULD be retrieved using a
203:             * GET method on that resource. This method exists primarily to allow the
204:             * output of a POST-activated script to redirect the user agent to a
205:             * selected resource. The new URI is not a substitute reference for the
206:             * originally requested resource.
207:             * 
208:             * @param targetRef
209:             *            The target reference.
210:             */
211:            public void redirectSeeOther(Reference targetRef) {
212:                setRedirectRef(targetRef);
213:                setStatus(Status.REDIRECTION_SEE_OTHER);
214:            }
215:
216:            /**
217:             * Temporarily redirects the client to a target URI. The client is expected
218:             * to reuse the same method for the new request.
219:             * 
220:             * @param targetUri
221:             *            The target URI.
222:             */
223:            public void redirectTemporary(String targetUri) {
224:                redirectTemporary(new Reference(targetUri));
225:            }
226:
227:            /**
228:             * Temporarily redirects the client to a target URI. The client is expected
229:             * to reuse the same method for the new request.
230:             * 
231:             * @param targetRef
232:             *            The target reference.
233:             */
234:            public void redirectTemporary(Reference targetRef) {
235:                setRedirectRef(targetRef);
236:                setStatus(Status.REDIRECTION_TEMPORARY);
237:            }
238:
239:            /**
240:             * Sets the authentication request sent by an origin server to a client.
241:             * 
242:             * @param request
243:             *            The authentication request sent by an origin server to a
244:             *            client.
245:             */
246:            public void setChallengeRequest(ChallengeRequest request) {
247:                this .challengeRequest = request;
248:            }
249:
250:            /**
251:             * Sets the reference that the client should follow for redirections or
252:             * resource creations.
253:             * 
254:             * @param redirectRef
255:             *            The redirection reference.
256:             */
257:            public void setRedirectRef(Reference redirectRef) {
258:                this .redirectRef = redirectRef;
259:            }
260:
261:            /**
262:             * Sets the reference that the client should follow for redirections or
263:             * resource creations.
264:             * 
265:             * @param redirectUri
266:             *            The redirection URI.
267:             */
268:            public void setRedirectRef(String redirectUri) {
269:                Reference baseRef = (getRequest().getResourceRef() != null) ? getRequest()
270:                        .getResourceRef().getBaseRef()
271:                        : null;
272:                setRedirectRef(new Reference(baseRef, redirectUri)
273:                        .getTargetRef());
274:            }
275:
276:            /**
277:             * Sets the associated request.
278:             * 
279:             * @param request
280:             *            The associated request
281:             */
282:            public void setRequest(Request request) {
283:                this .request = request;
284:            }
285:
286:            /**
287:             * Sets the status.
288:             * 
289:             * @param status
290:             *            The status to set.
291:             */
292:            public void setStatus(Status status) {
293:                this .status = status;
294:            }
295:
296:            /**
297:             * Sets the status.
298:             * 
299:             * @param status
300:             *            The status to set.
301:             * @param message
302:             *            The status message.
303:             */
304:            public void setStatus(Status status, String message) {
305:                setStatus(new Status(status, message));
306:            }
307:
308:            /**
309:             * Private cookie setting series.
310:             * 
311:             * @author Jerome Louvel (contact@noelios.com)
312:             */
313:            private static class CookieSettingSeries extends
314:                    Series<CookieSetting> {
315:                /**
316:                 * Constructor.
317:                 */
318:                public CookieSettingSeries() {
319:                    super ();
320:                }
321:
322:                /**
323:                 * Constructor.
324:                 * 
325:                 * @param delegate
326:                 *            The delegate list.
327:                 */
328:                public CookieSettingSeries(List<CookieSetting> delegate) {
329:                    super (delegate);
330:                }
331:
332:                @Override
333:                public CookieSetting createEntry(String name, String value) {
334:                    return new CookieSetting(name, value);
335:                }
336:
337:                @Override
338:                public Series<CookieSetting> createSeries(
339:                        List<CookieSetting> delegate) {
340:                    if (delegate != null)
341:                        return new CookieSettingSeries(delegate);
342:                    else
343:                        return new CookieSettingSeries();
344:                }
345:            }
346:
347:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.