Source Code Cross Referenced for Method.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:        /**
022:         * Method to execute when handling a call.
023:         * 
024:         * @author Jerome Louvel (contact@noelios.com)
025:         */
026:        public final class Method extends Metadata {
027:            private static final String BASE_HTTP = "http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html";
028:
029:            private static final String BASE_WEBDAV = "http://www.webdav.org/specs/rfc2518.html";
030:
031:            /**
032:             * Used with a proxy that can dynamically switch to being a tunnel.
033:             * 
034:             * @see <a
035:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.9">HTTP
036:             *      RFC - 9.9 CONNECT</a>
037:             */
038:            public static final Method CONNECT = new Method(
039:                    "CONNECT",
040:                    "Used with a proxy that can dynamically switch to being a tunnel",
041:                    BASE_HTTP + "#sec9.9");
042:
043:            /**
044:             * Creates a duplicate of the source resource, identified by the
045:             * Request-URI, in the destination resource, identified by the URI in the
046:             * Destination header.
047:             * 
048:             * @see <a
049:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_COPY">WEBDAV
050:             *      RFC - 8.8 COPY Method</a>
051:             */
052:            public static final Method COPY = new Method(
053:                    "COPY",
054:                    "Creates a duplicate of the source resource, identified by the Request-URI, in the destination resource, identified by the URI in the Destination header",
055:                    BASE_WEBDAV + "#METHOD_COPY");
056:
057:            /**
058:             * Requests that the origin server deletes the resource identified by the
059:             * request URI.
060:             * 
061:             * @see <a
062:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7">HTTP
063:             *      RFC - 9.7 DELETE</a>
064:             */
065:            public static final Method DELETE = new Method(
066:                    "DELETE",
067:                    "Requests that the origin server deletes the resource identified by the request URI",
068:                    BASE_HTTP + "#sec9.7");
069:
070:            /**
071:             * Retrieves whatever information (in the form of an entity) that is
072:             * identified by the request URI.
073:             * 
074:             * @see <a
075:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3">HTTP
076:             *      RFC - 9.3 GET</a>
077:             */
078:            public static final Method GET = new Method(
079:                    "GET",
080:                    "Retrieves whatever information (in the form of an entity) that is identified by the request URI",
081:                    BASE_HTTP + "#sec9.3");
082:
083:            /**
084:             * Identical to GET except that the server must not return a message body in
085:             * the response but only the message header.
086:             * 
087:             * @see <a
088:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4">HTTP
089:             *      RFC - 9.4 GET</a>
090:             */
091:            public static final Method HEAD = new Method(
092:                    "HEAD",
093:                    "Identical to GET except that the server must not return a message body in the response",
094:                    BASE_HTTP + "#sec9.4");
095:
096:            /**
097:             * Used to take out a lock of any access type on the resource identified by
098:             * the request URI.
099:             * 
100:             * @see <a
101:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_LOCK">WEBDAV
102:             *      RFC - 8.10 LOCK Method</a>
103:             */
104:            public static final Method LOCK = new Method("LOCK",
105:                    "Used to take out a lock of any access type (WebDAV)",
106:                    BASE_WEBDAV + "#METHOD_LOCK");
107:
108:            /**
109:             * MKCOL creates a new collection resource at the location specified by the
110:             * Request URI.
111:             * 
112:             * @see <a
113:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_MKCOL">WEBDAV
114:             *      RFC - 8.3 MKCOL Method</a>
115:             */
116:            public static final Method MKCOL = new Method("MKCOL",
117:                    "Used to create a new collection (WebDAV)", BASE_WEBDAV
118:                            + "#METHOD_MKCOL");
119:
120:            /**
121:             * Logical equivalent of a copy, followed by consistency maintenance
122:             * processing, followed by a delete of the source where all three actions
123:             * are performed atomically.
124:             * 
125:             * @see <a
126:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_MOVE">WEBDAV
127:             *      RFC - 8.3 MKCOL Method</a>
128:             */
129:            public static final Method MOVE = new Method(
130:                    "MOVE",
131:                    "Logical equivalent of a copy, followed by consistency maintenance processing, followed by a delete of the source (WebDAV)",
132:                    BASE_WEBDAV + "#METHOD_MOVE");
133:
134:            /**
135:             * Requests for information about the communication options available on the
136:             * request/response chain identified by the URI.
137:             * 
138:             * @see <a
139:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2">HTTP
140:             *      RFC - 9.2 OPTIONS</a>
141:             */
142:            public static final Method OPTIONS = new Method(
143:                    "OPTIONS",
144:                    "Requests for information about the communication options available on the request/response chain identified by the URI",
145:                    BASE_HTTP + "#sec9.2");
146:
147:            /**
148:             * Requests that the origin server accepts the entity enclosed in the
149:             * request as a new subordinate of the resource identified by the request
150:             * URI.
151:             * 
152:             * @see <a
153:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5">HTTP
154:             *      RFC - 9.5 POST</a>
155:             */
156:            public static final Method POST = new Method(
157:                    "POST",
158:                    "Requests that the origin server accepts the entity enclosed in the request as a new subordinate of the resource identified by the request URI",
159:                    BASE_HTTP + "#sec9.5");
160:
161:            /**
162:             * Retrieves properties defined on the resource identified by the request
163:             * URI.
164:             * 
165:             * @see <a
166:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_PROPFIND">WEBDAV
167:             *      RFC - 8.1 PROPFIND</a>
168:             */
169:            public static final Method PROPFIND = new Method(
170:                    "PROPFIND",
171:                    "Retrieves properties defined on the resource identified by the request URI",
172:                    BASE_WEBDAV + "#METHOD_PROPFIND");
173:
174:            /**
175:             * Processes instructions specified in the request body to set and/or remove
176:             * properties defined on the resource identified by the request URI.
177:             * 
178:             * @see <a
179:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_PROPPATCH">WEBDAV
180:             *      RFC - 8.2 PROPPATCH</a>
181:             */
182:            public static final Method PROPPATCH = new Method(
183:                    "PROPPATCH",
184:                    "Processes instructions specified in the request body to set and/or remove properties defined on the resource identified by the request URI",
185:                    BASE_WEBDAV + "#METHOD_PROPPATCH");
186:
187:            /**
188:             * Requests that the enclosed entity be stored under the supplied request
189:             * URI.
190:             * 
191:             * @see <a
192:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6">HTTP
193:             *      RFC - 9.6 PUT</a>
194:             */
195:            public static final Method PUT = new Method(
196:                    "PUT",
197:                    "Requests that the enclosed entity be stored under the supplied request URI",
198:                    BASE_HTTP + "#sec9.6");
199:
200:            /**
201:             * Used to invoke a remote, application-layer loop-back of the request
202:             * message.
203:             * 
204:             * @see <a
205:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.8">HTTP
206:             *      RFC - 9.8 TRACE</a>
207:             */
208:            public static final Method TRACE = new Method(
209:                    "TRACE",
210:                    "Used to invoke a remote, application-layer loop-back of the request message",
211:                    BASE_HTTP + "#sec9.8");
212:
213:            /**
214:             * Removes the lock identified by the lock token from the request URI, and
215:             * all other resources included in the lock.
216:             * 
217:             * @see <a
218:             *      href="http://www.webdav.org/specs/rfc2518.html#METHOD_UNLOCK">WEBDAV
219:             *      RFC - 8.11 UNLOCK Method</a>
220:             */
221:            public static final Method UNLOCK = new Method(
222:                    "UNLOCK",
223:                    "Removes the lock identified by the lock token from the request URI, and all other resources included in the lock",
224:                    BASE_WEBDAV + "#METHOD_UNLOCK");
225:
226:            /**
227:             * Returns the method associated to a given method name. If an existing
228:             * constant exists then it is returned, otherwise a new instance is created.
229:             * 
230:             * @param methodName
231:             *            The method name.
232:             * @return The associated method.
233:             */
234:            public static Method valueOf(final String methodName) {
235:                Method result = null;
236:
237:                if (methodName != null) {
238:                    if (methodName.equalsIgnoreCase(GET.getName()))
239:                        result = GET;
240:                    else if (methodName.equalsIgnoreCase(POST.getName()))
241:                        result = POST;
242:                    else if (methodName.equalsIgnoreCase(HEAD.getName()))
243:                        result = HEAD;
244:                    else if (methodName.equalsIgnoreCase(OPTIONS.getName()))
245:                        result = OPTIONS;
246:                    else if (methodName.equalsIgnoreCase(PUT.getName()))
247:                        result = PUT;
248:                    else if (methodName.equalsIgnoreCase(DELETE.getName()))
249:                        result = DELETE;
250:                    else if (methodName.equalsIgnoreCase(CONNECT.getName()))
251:                        result = CONNECT;
252:                    else if (methodName.equalsIgnoreCase(COPY.getName()))
253:                        result = COPY;
254:                    else if (methodName.equalsIgnoreCase(LOCK.getName()))
255:                        result = LOCK;
256:                    else if (methodName.equalsIgnoreCase(MKCOL.getName()))
257:                        result = MKCOL;
258:                    else if (methodName.equalsIgnoreCase(MOVE.getName()))
259:                        result = MOVE;
260:                    else if (methodName.equalsIgnoreCase(PROPFIND.getName()))
261:                        result = PROPFIND;
262:                    else if (methodName.equalsIgnoreCase(PROPPATCH.getName()))
263:                        result = PROPPATCH;
264:                    else if (methodName.equalsIgnoreCase(TRACE.getName()))
265:                        result = TRACE;
266:                    else if (methodName.equalsIgnoreCase(UNLOCK.getName()))
267:                        result = UNLOCK;
268:                    else
269:                        result = new Method(methodName);
270:                }
271:
272:                return result;
273:            }
274:
275:            /** The URI of the specification describing the method. */
276:            private String uri;
277:
278:            /**
279:             * Constructor.
280:             * 
281:             * @param name
282:             *            The technical name of the method.
283:             * @see org.restlet.data.Method#valueOf(String)
284:             */
285:            public Method(final String name) {
286:                this (name, null, null);
287:            }
288:
289:            /**
290:             * Constructor.
291:             * 
292:             * @param name
293:             *            The technical name of the method.
294:             * @param description
295:             *            The description.
296:             * @see org.restlet.data.Method#valueOf(String)
297:             */
298:            public Method(final String name, final String description) {
299:                this (name, description, null);
300:            }
301:
302:            /**
303:             * Constructor.
304:             * 
305:             * @param name
306:             *            The technical name.
307:             * @param description
308:             *            The description.
309:             * @param uri
310:             *            The URI of the specification describing the method.
311:             * @see org.restlet.data.Method#valueOf(String)
312:             */
313:            public Method(final String name, final String description,
314:                    final String uri) {
315:                super (name, description);
316:                this .uri = uri;
317:            }
318:
319:            /** {@inheritDoc} */
320:            @Override
321:            public boolean equals(final Object object) {
322:                return (object instanceof  Method)
323:                        && ((Method) object).getName().equals(getName());
324:            }
325:
326:            /**
327:             * Returns the URI of the specification describing the method.
328:             * 
329:             * @return The URI of the specification describing the method.
330:             */
331:            public String getUri() {
332:                return this .uri;
333:            }
334:
335:            /** {@inheritDoc} */
336:            @Override
337:            public int hashCode() {
338:                return (getName() == null) ? 0 : getName().hashCode();
339:            }
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.