1 16 package org.apache.commons.latka.http; 17 18 import java.net.URL ; 19 20 import org.apache.commons.httpclient.HttpMethod; 21 import org.apache.commons.httpclient.methods.GetMethod; 22 import org.apache.commons.httpclient.methods.PostMethod; 23 import org.apache.commons.httpclient.methods.HeadMethod; 24 25 31 public final class MethodFactory { 32 33 36 private MethodFactory() { 37 } 38 39 46 public static HttpMethod getInstance(int method, URL url) { 47 HttpMethod httpMethod = null; 48 switch (method) { 49 case Request.HTTP_METHOD_GET: 50 httpMethod = new GetMethod(url.getPath()); 51 break; 52 case Request.HTTP_METHOD_POST: 53 httpMethod = new PostMethod(url.getPath()); 54 break; 55 case Request.HTTP_METHOD_HEAD: 56 httpMethod = new HeadMethod(url.getPath()); 57 break; 58 default: 59 throw new IllegalArgumentException ("Unsupported HTTP Method"); 60 } 61 return httpMethod; 62 } 63 } 64 65 | Popular Tags |