1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.filter;
22
23 import net.sf.jour.log.Logger;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class PointcutParamsFilter extends MatchStringListFilter {
39
40 protected static final Logger log = Logger.getLogger();
41
42 boolean matchAny = false;
43
44 PointcutParamsFilter nextParam = null;
45
46 public PointcutParamsFilter() {
47
48 }
49
50 public PointcutParamsFilter(String params) {
51 setParams(params);
52 }
53
54 public void debug() {
55 log.debug("matchAny " + matchAny);
56 log.debug("has nextParam " + (nextParam != null));
57 super.debug();
58 }
59
60 public void setParams(String params) {
61 params = params.trim();
62 if (params.equals("..")) {
63 this.matchAny = true;
64 return;
65 }
66 int idx = params.indexOf(",");
67 if (idx == -1) {
68 super.addPatterns(params);
69 return;
70 }
71
72 String firstParam = params.substring(0, idx);
73
74
75
76 super.addPatterns(firstParam);
77 this.nextParam = new PointcutParamsFilter(params.substring(idx + 1));
78 }
79
80 public int matchState(Object obj) {
81
82 if (debug) {
83 debug();
84 }
85
86 if (obj instanceof String) {
87 return super.matchState(obj);
88 }
89 if (!(obj instanceof String[])) {
90 return MATCH_NO;
91 }
92 if (matchAny) {
93 return MATCH_YES;
94 }
95
96 String[] params = (String[]) obj;
97
98 if (params.length == 0) {
99 if (isEmpty()) {
100 return MATCH_YES;
101 } else {
102 return MATCH_NO;
103 }
104 }
105
106 if (!super.match(params[0])) {
107 return MATCH_NO;
108 }
109
110 if (this.nextParam == null) {
111 return MATCH_YES;
112 }
113
114 String[] nextParams = new String[params.length - 1];
115 for (int i = 1; i < params.length; i++) {
116 nextParams[i - 1] = params[i];
117 }
118
119 return this.nextParam.matchState(nextParams);
120 }
121
122 }