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.v2.communication; 21 22 import org.apache.http.client.methods.HttpDelete; 23 import org.apache.http.client.methods.HttpGet; 24 import org.apache.http.client.methods.HttpHead; 25 import org.apache.http.client.methods.HttpPost; 26 import org.apache.http.client.methods.HttpPut; 27 import org.apache.http.client.methods.HttpRequestBase; 28 29 /** 30 * The Enum HTTPMethods for the new version of the httpClient. 31 * 32 * <p> 33 * <b> $Id: HTTPMethods.java 183 2010-12-17 19:10:21Z georgosn $</b> 34 * </p> 35 * 36 * @author $LastChangedBy: georgosn $ 37 * @version $LastChangedRevision: 183 $ 38 */ 39 public enum HTTPMethods { 40 /** The HEAD. */ 41 HEAD, /** The GET. */ 42 GET, /** The POST. */ 43 POST, /** The DELETE. */ 44 DELETE, /** The PUT. */ 45 PUT; 46 47 /** 48 * Returns the method to be used as an HttpRequestBase object. 49 * 50 * @param source 51 * the source 52 * @return the method 53 */ 54 public HttpRequestBase getMethod(final String source) { 55 switch (this) { 56 case GET: 57 return new HttpGet(source); 58 case PUT: 59 return new HttpPut(source); 60 case POST: 61 return new HttpPost(source); 62 case DELETE: 63 return new HttpDelete(source); 64 default: 65 return new HttpHead(source); 66 } 67 } 68 }