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