Clover Coverage Report - ARESTC 0.1.7-SNAPSHOT
Coverage timestamp: Fri Aug 27 2010 19:12:04 CEST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
13   88   7   4.33
0   36   0.54   3
3     2.33  
1    
 
  HTTPMethods       Line # 35 13 0% 7 0 100% 1.0
 
  (9)
 
1    /*
2    *
3    * (C)opyright 2010, Nikolaos Georgosopoulos
4    *
5    * This file is part of ARESTC.
6    *
7    * ARESTC is free software: you can redistribute it and/or modify it under the
8    * terms of the Lesser General Public License as published by the Free Software
9    * Foundation, either version 3 of the License, or (at your option) any later
10    * version.
11    *
12    * ARESTC is distributed in the hope that it will be useful, but WITHOUT ANY
13    * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14    * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15    *
16    * You should have received a copy of the Lesser General Public License along
17    * with ARESTC. If not, see <http://www.gnu.org/licenses/>.
18    */
19   
20    package net.sf.arestc.core.services;
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    // TODO: Auto-generated Javadoc
30    /**
31    * The Enum HTTPMethods.
32    *
33    * @author georgosn
34    */
 
35    public enum HTTPMethods {
36   
37    /** The HEAD. */
38    HEAD("{0}?{1}"), /** The HEAD method enum. */
39    GET("{0}?{1}"), /** The Get method enum. */
40    POST("{0}"), /** The Post method enum. */
41    DELETE("{0}?{1}"), /** The Delete method enum. */
42    PUT("{0}"),
43    /** the Put method enum. */
44    ;
45   
46    private String urlPattern;
47   
48    /**
49    * Instantiates a new hTTP methods.
50    *
51    * @param pattern
52    * the pattern
53    */
 
54  5 toggle private HTTPMethods(final String pattern) {
55  5 urlPattern = pattern;
56    }
57   
58    /**
59    * Gets the method.
60    *
61    * @param source
62    * the source
63    * @return the method
64    */
 
65  15 toggle public HttpMethod getMethod(final String source) {
66  15 switch (this) {
67  7 case GET:
68  7 return new GetMethod(source);
69  2 case PUT:
70  2 return new PutMethod(source);
71  3 case POST:
72  3 return new PostMethod(source);
73  2 case DELETE:
74  2 return new DeleteMethod(source);
75  1 default:
76  1 return new HeadMethod(source);
77    }
78    }
79   
80    /**
81    * Gets the uRL pattern.
82    *
83    * @return the uRL pattern
84    */
 
85  10 toggle public String getURLPattern() {
86  10 return urlPattern;
87    }
88    }