1 /*
2 * (C)opyright 2010, Nikolaos Georgosopoulos
3 *
4 * This file is part of URLChecker.
5
6 URLChecker is free software: you can redistribute it and/or modify
7 it under the terms of the Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 URLChecker is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the Lesser General Public License
17 along with URLChecker. If not, see <http://www.gnu.org/licenses/>.
18
19 */
20 package net.sf.urlchecker.communication;
21
22 import org.apache.commons.httpclient.HttpMethod;
23 import org.apache.commons.httpclient.methods.DeleteMethod;
24 import org.apache.commons.httpclient.methods.GetMethod;
25 import org.apache.commons.httpclient.methods.HeadMethod;
26 import org.apache.commons.httpclient.methods.PostMethod;
27 import org.apache.commons.httpclient.methods.PutMethod;
28
29 /**
30 * The Enum HTTPMethods.
31 *
32 * <p>
33 * <b> $Id: HTTPMethods.java 182 2010-12-13 22:51:53Z georgosn $</b>
34 * </p>
35 *
36 * @author $LastChangedBy: georgosn $
37 * @version $LastChangedRevision: 182 $
38 */
39 public enum HTTPMethods {
40
41 /** The HEAD. */
42 HEAD, /** The GET. */
43 GET, /** The POST. */
44 POST, /** The DELETE. */
45 DELETE, /** The PUT. */
46 PUT;
47
48 /**
49 * Gets the method.
50 *
51 * @param source
52 * the source
53 * @return the method
54 */
55 public HttpMethod getMethod(final String source) {
56 switch (this) {
57 case GET:
58 return new GetMethod(source);
59 case PUT:
60 return new PutMethod(source);
61 case POST:
62 return new PostMethod(source);
63 case DELETE:
64 return new DeleteMethod(source);
65 default:
66 return new HeadMethod(source);
67 }
68 }
69 }