freemarker.cache

## Class PathGlobMatcher

- java.lang.Object
- - freemarker.cache.TemplateSourceMatcher
  - - freemarker.cache.PathGlobMatcher

    public class PathGlobMatcher
    extends TemplateSourceMatcher

Matches the whole template source name (also known as template source path) with the given glob. Note that the template source name is relative to the template storage root defined by the `TemplateLoader`; it's not the full path of a file on the file system.

This glob implementation recognizes `**` (Ant-style directory wildcard) among others. For more details see `StringUtil.globToRegularExpression(String, boolean)`.

About the usage of `/` (slash):

- You aren't allowed to start the glob with `/`, because template names (template paths) never start with it.
- Future FreeMarker versions (compared to 2.3.24) might will support importing whole directories. Directory paths in FreeMarker should end with `/`. Hence, `foo/bar` refers to the file {bar}, while `foo/bar/` refers to the {bar} directory.

By default the glob is case sensitive, but this can be changed with `setCaseInsensitive(boolean)` (or `caseInsensitive(boolean)`).

Since:
  2.3.24

### Constructor Summary

Constructors
Constructor and Description
`PathGlobMatcher(String glob)`

### Method Summary

All Methods Instance Methods Concrete Methods
`PathGlobMatcher` `caseInsensitive(boolean caseInsensitive)` Fluid API variation of `setCaseInsensitive(boolean)`
`boolean` `isCaseInsensitive()`
`boolean` `matches(String sourceName, Object templateSource)`
`void` `setCaseInsensitive(boolean caseInsensitive)` Sets if the matching will be case insensitive (UNICODE compliant); default is `false`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PathGlobMatcher

    public PathGlobMatcher(String glob)

Parameters:
  `glob` - Glob with the syntax defined by `StringUtil.globToRegularExpression(String, boolean)`. Must not start with `/`.

### Method Detail

#### matches

    public boolean matches(String sourceName,
                           Object templateSource)
                    throws IOException

Throws:
  `IOException`

#### isCaseInsensitive

    public boolean isCaseInsensitive()

#### setCaseInsensitive

    public void setCaseInsensitive(boolean caseInsensitive)

Sets if the matching will be case insensitive (UNICODE compliant); default is `false`.

#### caseInsensitive

    public PathGlobMatcher caseInsensitive(boolean caseInsensitive)

Fluid API variation of `setCaseInsensitive(boolean)`