001 /* 002 * Copyright 2003-2008 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * You are receiving this code free of charge, which represents many hours of 017 * effort from other individuals and corporations. As a responsible member 018 * of the community, you are asked (but not required) to donate any 019 * enhancements or improvements back to the community under a similar open 020 * source license. Thank you. -TMN 021 */ 022 package groovyx.net.http; 023 024 import org.apache.http.HttpRequest; 025 import org.apache.http.client.methods.HttpDelete; 026 import org.apache.http.client.methods.HttpGet; 027 import org.apache.http.client.methods.HttpHead; 028 import org.apache.http.client.methods.HttpPost; 029 import org.apache.http.client.methods.HttpPut; 030 import org.apache.http.client.methods.HttpRequestBase; 031 032 /** 033 * Enumeration of valid HTTP methods that may be used in a 034 * {@link HTTPBuilder#request(Method, groovy.lang.Closure) request} call. 035 * @author tnichols 036 */ 037 public enum Method { 038 GET( HttpGet.class ), 039 PUT( HttpPut.class ), 040 POST( HttpPost.class ), 041 DELETE( HttpDelete.class ), 042 HEAD( HttpHead.class ); 043 044 private final Class<? extends HttpRequestBase> requestType; 045 046 /** 047 * Get the HttpRequest class that represents this request type. 048 * @return a non-abstract class that implements {@link HttpRequest} 049 */ 050 public Class<? extends HttpRequestBase> getRequestType() { return this.requestType; } 051 052 private Method( Class<? extends HttpRequestBase> type ) { 053 this.requestType = type; 054 } 055 }