01: /*
02: * argun 1.0
03: * Web 2.0 delivery framework
04: * Copyright (C) 2007 Hammurapi Group
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * URL: http://www.hammurapi.biz
21: * e-Mail: support@hammurapi.biz
22: */
23: package biz.hammurapi.web.menu.matchers;
24:
25: import java.util.List;
26: import java.util.regex.Pattern;
27: import java.util.regex.PatternSyntaxException;
28:
29: import javax.servlet.http.HttpServletRequest;
30: import javax.xml.transform.TransformerException;
31:
32: import org.apache.xpath.CachedXPathAPI;
33: import org.w3c.dom.Element;
34:
35: import biz.hammurapi.web.HammurapiWebException;
36:
37: /*
38: * argun 1.0
39: * Web 2.0 delivery framework
40: * Copyright (C) 2007 Hammurapi Group
41: *
42: * This program is free software; you can redistribute it and/or
43: * modify it under the terms of the GNU Lesser General Public
44: * License as published by the Free Software Foundation; either
45: * version 2 of the License, or (at your option) any later version.
46: *
47: * This program is distributed in the hope that it will be useful,
48: * but WITHOUT ANY WARRANTY; without even the implied warranty of
49: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50: * Lesser General Public License for more details.
51: *
52: * You should have received a copy of the GNU Lesser General Public
53: * License along with this library; if not, write to the Free Software
54: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
55: *
56: * URL: http://www.hammurapi.biz
57: * e-Mail: support@hammurapi.biz
58: */
59:
60: /**
61: * @author Pavel Vlasov
62: * @version $Revision: 1.1 $
63: */
64: public class Re14UriMatcher extends UriMatcher {
65: Pattern re14Pattern;
66:
67: /**
68: * @param holder
69: * @param cxpa
70: * @throws TransformerException
71: * @throws PatternSyntaxException
72: */
73: public Re14UriMatcher(Element holder, String baseUri,
74: CachedXPathAPI cxpa) throws HammurapiWebException {
75: super (holder, baseUri, cxpa);
76: this .re14Pattern = Pattern.compile(getAbsolutePattern());
77: }
78:
79: /**
80: * @param pattern
81: * @param matchQueryString
82: * @param weight
83: * @throws PatternSyntaxException
84: */
85: public Re14UriMatcher(String pattern, String baseUri,
86: boolean matchQueryString, int weight)
87: throws HammurapiWebException {
88: super (pattern, baseUri, matchQueryString, weight);
89: this .re14Pattern = Pattern.compile(getAbsolutePattern());
90: }
91:
92: public List match(HttpServletRequest request) {
93: return matchResult(re14Pattern.matcher(
94: getStringToMatch(request)).matches());
95: }
96: }
|