1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.urlchecker.communication.configurers;
21
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import net.sf.urlchecker.communication.HTTPMethods;
27
28 import org.apache.commons.configuration.HierarchicalConfiguration;
29 import org.apache.commons.configuration.XMLConfiguration;
30
31
32
33
34
35
36
37
38
39
40
41 public class MethodsConfigurer implements Configurer<Map<String, HTTPMethods>> {
42
43
44
45
46
47
48
49
50
51 public Map<String, HTTPMethods> configureWith(XMLConfiguration config) {
52 final Map<String, HTTPMethods> methods = new HashMap<String, HTTPMethods>();
53 if (config.containsKey("methods.method")) {
54 final List<HierarchicalConfiguration> methodsConfig = config
55 .configurationsAt("methods.method");
56 if (null != methodsConfig) {
57 for (final HierarchicalConfiguration method : methodsConfig) {
58 if ("*".equals(method.getString("[@source]"))) {
59 methods.put(null, HTTPMethods.valueOf(method.getString(
60 "[@type]", "HEAD")));
61 } else {
62 methods.put(method.getString("[@source]"), HTTPMethods
63 .valueOf(method.getString("[@type]", "HEAD")));
64 }
65 }
66 }
67 }
68 return methods;
69 }
70
71 }