Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.sitemap.util
Class WildcardMatcherHelper

    java.lang.Object
      org.apache.cocoon.sitemap.util.WildcardMatcherHelper

    public class WildcardMatcherHelper

extends Object

This class is an utility class that perform wildcard-patterns matching and isolation.

Version:
  $Id: WildcardMatcherHelper.java 737809 2009-01-26 20:12:55Z cziegeler $

Field Summary
`static char` | `ESC` Default path separator: "/"
`static char` | `PATHSEP` Default path separator: "/"
`static char` | `STAR` Default path separator: "/"

Constructor Summary
`WildcardMatcherHelper()`

Method Summary
`static Map<String,String>` | `match(String pat, String str)` Match a pattern agains a string and isolates wildcard replacement into a `Map`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ESC

    public static final char ESC

  Default path separator: "/"

  See Also:
    Constant Field Values

### PATHSEP

    public static final char PATHSEP

  Default path separator: "/"

  See Also:
    Constant Field Values

### STAR

    public static final char STAR

  Default path separator: "/"

  See Also:
    Constant Field Values

Constructor Detail

### WildcardMatcherHelper

    public WildcardMatcherHelper()

Method Detail

### match

    public static Map<String,String> 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.
    `str` - The string to math agains the pattern
  Returns:
    a `Map` containing the representation of the extracted pattern. The extracted patterns are keys 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 the pattern .

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright � 2008-2010 The Apache Software Foundation. All Rights Reserved.