]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.osgi.boot/src/org/argeo/osgi/boot/internal/springutil/PathMatcher.java
Increase release number for TP.
[lgpl/argeo-commons.git] / org.argeo.osgi.boot / src / org / argeo / osgi / boot / internal / springutil / PathMatcher.java
1 /*
2 * Copyright 2002-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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
17 package org.argeo.osgi.boot.internal.springutil;
18
19 /**
20 * Strategy interface for <code>String</code>-based path matching.
21 *
22 * <p>Used by {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver},
23 * {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},
24 * {@link org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver},
25 * and {@link org.springframework.web.servlet.mvc.WebContentInterceptor}.
26 *
27 * <p>The default implementation is {@link AntPathMatcher}, supporting the
28 * Ant-style pattern syntax.
29 *
30 * @author Juergen Hoeller
31 * @since 1.2
32 * @see AntPathMatcher
33 */
34 public interface PathMatcher {
35
36 /**
37 * Does the given <code>path</code> represent a pattern that can be matched
38 * by an implementation of this interface?
39 * <p>If the return value is <code>false</code>, then the {@link #match}
40 * method does not have to be used because direct equality comparisons
41 * on the static path Strings will lead to the same result.
42 * @param path the path String to check
43 * @return <code>true</code> if the given <code>path</code> represents a pattern
44 */
45 boolean isPattern(String path);
46
47 /**
48 * Match the given <code>path</code> against the given <code>pattern</code>,
49 * according to this PathMatcher's matching strategy.
50 * @param pattern the pattern to match against
51 * @param path the path String to test
52 * @return <code>true</code> if the supplied <code>path</code> matched,
53 * <code>false</code> if it didn't
54 */
55 boolean match(String pattern, String path);
56
57 /**
58 * Match the given <code>path</code> against the corresponding part of the given
59 * <code>pattern</code>, according to this PathMatcher's matching strategy.
60 * <p>Determines whether the pattern at least matches as far as the given base
61 * path goes, assuming that a full path may then match as well.
62 * @param pattern the pattern to match against
63 * @param path the path String to test
64 * @return <code>true</code> if the supplied <code>path</code> matched,
65 * <code>false</code> if it didn't
66 */
67 boolean matchStart(String pattern, String path);
68
69 /**
70 * Given a pattern and a full path, determine the pattern-mapped part.
71 * <p>This method is supposed to find out which part of the path is matched
72 * dynamically through an actual pattern, that is, it strips off a statically
73 * defined leading path from the given full path, returning only the actually
74 * pattern-matched part of the path.
75 * <p>For example: For "myroot/*.html" as pattern and "myroot/myfile.html"
76 * as full path, this method should return "myfile.html". The detailed
77 * determination rules are specified to this PathMatcher's matching strategy.
78 * <p>A simple implementation may return the given full path as-is in case
79 * of an actual pattern, and the empty String in case of the pattern not
80 * containing any dynamic parts (i.e. the <code>pattern</code> parameter being
81 * a static path that wouldn't qualify as an actual {@link #isPattern pattern}).
82 * A sophisticated implementation will differentiate between the static parts
83 * and the dynamic parts of the given path pattern.
84 * @param pattern the path pattern
85 * @param path the full path to introspect
86 * @return the pattern-mapped part of the given <code>path</code>
87 * (never <code>null</code>)
88 */
89 String extractPathWithinPattern(String pattern, String path);
90
91 }