| java.lang.Object org.apache.cocoon.util.WildcardMatcherHelper
WildcardMatcherHelper | public class WildcardMatcherHelper (Code) | | This class is an utility class that perform wildcard-patterns matching and isolation.
version: $Id: WildcardMatcherHelper.java 448573 2006-09-21 14:52:23Z anathaniel $ |
Field Summary | |
final public static char | ESC | final public static char | PATHSEP | final public static char | STAR |
Method Summary | |
public static Map | match(String pat, String str) Match a pattern agains a string and isolates wildcard replacement into a Map .
Here is how the matching algorithm works:
-
The '*' character, meaning that zero or more characters (excluding the path separator '/')
are to be matched.
-
The '**' sequence, meaning that zero or more characters (including the path separator '/')
are to be matched.
-
The '\*' sequence is honored as a litteral '*' character, not a wildcard
When more than two '*' characters, not separated by another character, are found their value is
considered as '**' and immediate succeeding '*' are skipped.
The '**' wildcard is greedy and thus the following sample matches as {"foo/bar","baz","bug"}:
- pattern
- STAR,STAR,PATHSEP,STAR,PATHSEP,STAR,STAR (why can't I express it litterally?)
- string
- foo/bar/baz/bug
The first '**' in the pattern will suck up as much as possible without making the match fail.
Parameters: pat - The pattern string. Parameters: str - The string to math agains the pattern a Map containing the representation of the extracted pattern. |
ESC | final public static char ESC(Code) | | Default path separator: "/"
|
PATHSEP | final public static char PATHSEP(Code) | | Default path separator: "/"
|
STAR | final public static char STAR(Code) | | Default path separator: "/"
|
match | public static Map match(String pat, String str)(Code) | | Match a pattern agains a string and isolates wildcard replacement into a Map .
Here is how the matching algorithm works:
-
The '*' character, meaning that zero or more characters (excluding the path separator '/')
are to be matched.
-
The '**' sequence, meaning that zero or more characters (including the path separator '/')
are to be matched.
-
The '\*' sequence is honored as a litteral '*' character, not a wildcard
When more than two '*' characters, not separated by another character, are found their value is
considered as '**' and immediate succeeding '*' are skipped.
The '**' wildcard is greedy and thus the following sample matches as {"foo/bar","baz","bug"}:
- pattern
- STAR,STAR,PATHSEP,STAR,PATHSEP,STAR,STAR (why can't I express it litterally?)
- string
- foo/bar/baz/bug
The first '**' in the pattern will suck up as much as possible without making the match fail.
Parameters: pat - The pattern string. Parameters: str - The string to math agains the pattern a Map containing the representation of the extracted pattern. The extracted patterns arekeys in the Map from left to right beginning with "1" for te left most, "2" for the next,a.s.o. The key "0" is the string itself. If the return value is null, string does not match to thepattern . |
|
|