1 package org.seasar.cubby.routing.impl;
2
3 import java.lang.reflect.Method;
4 import java.util.List;
5 import java.util.regex.Pattern;
6
7 import org.seasar.cubby.action.Action;
8 import org.seasar.cubby.action.RequestMethod;
9 import org.seasar.cubby.routing.Routing;
10 import org.seasar.framework.util.StringUtil;
11
12
13
14
15
16
17
18 class RoutingImpl implements Routing {
19
20
21 private final Class<? extends Action> actionClass;
22
23
24 private final Method method;
25
26
27 private final String actionPath;
28
29
30 private final List<String> uriParameterNames;
31
32
33 private final Pattern pattern;
34
35
36 private final RequestMethod requestMethod;
37
38
39 private final String onSubmit;
40
41
42 private final int priority;
43
44
45 private final boolean auto;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 RoutingImpl(final Class<? extends Action> actionClass, final Method method,
70 final String actionPath, final List<String> uriParameterNames,
71 final Pattern pattern, final RequestMethod requestMethod,
72 final String onSubmit, final int priority, final boolean auto) {
73 this.actionClass = actionClass;
74 this.method = method;
75 this.actionPath = actionPath;
76 this.uriParameterNames = uriParameterNames;
77 this.pattern = pattern;
78 this.requestMethod = requestMethod;
79 this.onSubmit = onSubmit;
80 this.priority = priority;
81 this.auto = auto;
82 }
83
84
85
86
87 public Class<? extends Action> getActionClass() {
88 return actionClass;
89 }
90
91
92
93
94 public Method getMethod() {
95 return method;
96 }
97
98
99
100
101 public String getActionPath() {
102 return actionPath;
103 }
104
105
106
107
108 public List<String> getUriParameterNames() {
109 return uriParameterNames;
110 }
111
112
113
114
115 public Pattern getPattern() {
116 return pattern;
117 }
118
119
120
121
122 public RequestMethod getRequestMethod() {
123 return requestMethod;
124 }
125
126
127
128
129 public String getOnSubmit() {
130 return onSubmit;
131 }
132
133
134
135
136 public int getPriority() {
137 return this.priority;
138 }
139
140
141
142
143 public boolean isAuto() {
144 return auto;
145 }
146
147
148
149
150 public boolean isAcceptable(final String requestMethod) {
151 return StringUtil.equalsIgnoreCase(this.requestMethod.name(),
152 requestMethod);
153 }
154
155
156
157
158
159
160 @Override
161 public String toString() {
162 return new StringBuilder().append("[regex=").append(this.pattern)
163 .append(",method=").append(this.method).append(
164 ",uriParameterNames=").append(this.uriParameterNames)
165 .append(",requestMethod=").append(this.requestMethod).append(
166 ",onSubmit=").append(onSubmit).append(",priority=")
167 .append(this.priority).append(",auto=").append(this.auto)
168 .append("]").toString();
169 }
170 }