01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.myfaces.shared_impl.webapp.webxml;
17:
18: /**
19: * @author Manfred Geiler (latest modification by $Author: mbr $)
20: * @version $Revision: 517401 $ $Date: 2007-03-12 22:16:32 +0100 (Mo, 12 Mrz 2007) $
21: */
22: public class ServletMapping {
23: private final String _servletName;
24: private final Class _servletClass;
25: private final String _urlPattern;
26: private final String _extension;
27: private final String _prefix;
28:
29: public ServletMapping(String servletName, Class servletClass,
30: String urlPattern) {
31: _servletName = servletName;
32: _servletClass = servletClass;
33: _urlPattern = urlPattern;
34: _extension = _urlPattern != null
35: && _urlPattern.startsWith("*.") ? _urlPattern
36: .substring(_urlPattern.indexOf('.')) : null;
37: if (_extension == null) {
38: int index = _urlPattern.indexOf("/*");
39: if (index != -1) {
40: _prefix = _urlPattern.substring(0, _urlPattern
41: .indexOf("/*"));
42: } else {
43: _prefix = _urlPattern;
44: }
45: } else {
46: _prefix = null;
47: }
48: }
49:
50: public boolean isExtensionMapping() {
51: return _extension != null;
52: }
53:
54: public String getExtension() {
55: return _extension;
56: }
57:
58: public String getPrefix() {
59: return _prefix;
60: }
61:
62: public String getServletName() {
63: return _servletName;
64: }
65:
66: public Class getServletClass() {
67: return _servletClass;
68: }
69:
70: public String getUrlPattern() {
71: return _urlPattern;
72: }
73: }
|