*/
public ActionConfig lookup(String actionPath, String method) {
// 1st try: the map
ActionConfigSet actionConfigSet = map.get(actionPath);
if (actionConfigSet != null) {
ActionConfig actionConfig = actionConfigSet.lookup(method);
if (actionConfig != null) {
return actionConfig;
}
}
// 2nd try: the list
int actionPathDeep = StringUtil.count(actionPath, '/');
int len = list.size();
int lastMatched = -1;
int maxMatchedChars = -1;
for (int i = 0; i < len; i++) {
actionConfigSet = list.get(i);
int deep = actionConfigSet.deep;
if (deep < actionPathDeep) {
continue;
}
if (deep > actionPathDeep) {
break;
}
// same deep level, try the fully match
int matchedChars = actionConfigSet.actionPathMacros.match(actionPath);
if (matchedChars == -1) {
continue;
}
if (matchedChars > maxMatchedChars) {
maxMatchedChars = matchedChars;
lastMatched = i;
}
}
if (lastMatched < 0) {
return null;
}
ActionConfigSet set = list.get(lastMatched);
return set.lookup(method);
}