Groovy Documentation

org.codehaus.groovy.grails.io.support
[Java] Class AntPathMatcher

java.lang.Object
  org.codehaus.groovy.grails.io.support.AntPathMatcher

public class AntPathMatcher
extends java.lang.Object

PathMatcher implementation for Ant-style path patterns. Examples are provided below.

Part of this mapping code has been kindly borrowed from Apache Ant.

The mapping matches URLs using the following rules:

Some examples:

Authors:
Alef Arendsen
Juergen Hoeller
Rob Harrop
Arjen Poutsma
Since:
16.07.2003


Field Summary
static java.lang.String DEFAULT_PATH_SEPARATOR

Default path separator: "/"

 
Method Summary
java.lang.String combine(java.lang.String pattern1, java.lang.String pattern2)

static int countOccurrencesOf(java.lang.String str, java.lang.String sub)

Count the occurrences of the substring in string s.

protected boolean doMatch(java.lang.String pattern, java.lang.String path, boolean fullMatch, java.util.Map uriTemplateVariables)

Actually match the given path against the given pattern.

java.lang.String extractPathWithinPattern(java.lang.String pattern, java.lang.String path)

' and '/docs/cvs/commit -> 'cvs/commit'

  • '/docs/**\/*.html' and '/docs/cvs/commit.html -> 'cvs/commit.html'
  • '/*.html' and '/docs/cvs/commit.html -> 'docs/cvs/commit.html'
  • '*.html' and '/docs/cvs/commit.html -> '/docs/cvs/commit.html'
  • '*' and '/docs/cvs/commit.html -> '/docs/cvs/commit.html'
  • java.util.Map extractUriTemplateVariables(java.lang.String pattern, java.lang.String path)

    java.util.Comparator getPatternComparator(java.lang.String path)

    boolean isPattern(java.lang.String path)

    boolean match(java.lang.String pattern, java.lang.String path)

    boolean matchStart(java.lang.String pattern, java.lang.String path)

    void setPathSeparator(java.lang.String pathSeparator)

    Set the path separator to use for pattern parsing.

     
    Methods inherited from class java.lang.Object
    java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
     

    Field Detail

    DEFAULT_PATH_SEPARATOR

    public static final java.lang.String DEFAULT_PATH_SEPARATOR
    Default path separator: "/"


     
    Method Detail

    combine

    public java.lang.String combine(java.lang.String pattern1, java.lang.String pattern2)


    countOccurrencesOf

    public static int countOccurrencesOf(java.lang.String str, java.lang.String sub)
    Count the occurrences of the substring in string s.
    Parameters:
    str - string to search in. Return 0 if this is null.
    sub - string to search for. Return 0 if this is null.


    doMatch

    protected boolean doMatch(java.lang.String pattern, java.lang.String path, boolean fullMatch, java.util.Map uriTemplateVariables)
    Actually match the given path against the given pattern.
    Parameters:
    pattern - the pattern to match against
    path - the path String to test
    fullMatch - whether a full pattern match is required (else a pattern match as far as the given base path goes is sufficient)
    Returns:
    true if the supplied path matched, false if it didn't


    extractPathWithinPattern

    public java.lang.String extractPathWithinPattern(java.lang.String pattern, java.lang.String path)
    ' and '/docs/cvs/commit -> 'cvs/commit'
  • '/docs/**\/*.html' and '/docs/cvs/commit.html -> 'cvs/commit.html'
  • '/*.html' and '/docs/cvs/commit.html -> 'docs/cvs/commit.html'
  • '*.html' and '/docs/cvs/commit.html -> '/docs/cvs/commit.html'
  • '*' and '/docs/cvs/commit.html -> '/docs/cvs/commit.html'
  • Assumes that match returns true for 'pattern' and 'path', but does not enforce this.


    extractUriTemplateVariables

    public java.util.Map extractUriTemplateVariables(java.lang.String pattern, java.lang.String path)


    getPatternComparator

    public java.util.Comparator getPatternComparator(java.lang.String path)


    isPattern

    public boolean isPattern(java.lang.String path)


    match

    public boolean match(java.lang.String pattern, java.lang.String path)


    matchStart

    public boolean matchStart(java.lang.String pattern, java.lang.String path)


    setPathSeparator

    public void setPathSeparator(java.lang.String pathSeparator)
    Set the path separator to use for pattern parsing. Default is "/", as in Ant.


     

    Groovy Documentation