Package 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 theTemplateLoader
; 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 seeStringUtil.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}, whilefoo/bar/
refers to the {bar} directory.
By default the glob is case sensitive, but this can be changed with
setCaseInsensitive(boolean)
(orcaseInsensitive(boolean)
).- Since:
- 2.3.24
- You aren't allowed to start the glob with
-
-
Constructor Summary
Constructors Constructor Description PathGlobMatcher(java.lang.String glob)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PathGlobMatcher
caseInsensitive(boolean caseInsensitive)
Fluid API variation ofsetCaseInsensitive(boolean)
boolean
isCaseInsensitive()
boolean
matches(java.lang.String sourceName, java.lang.Object templateSource)
void
setCaseInsensitive(boolean caseInsensitive)
Sets if the matching will be case insensitive (UNICODE compliant); default isfalse
.
-
-
-
Constructor Detail
-
PathGlobMatcher
public PathGlobMatcher(java.lang.String glob)
- Parameters:
glob
- Glob with the syntax defined byStringUtil.globToRegularExpression(String, boolean)
. Must not start with/
.
-
-
Method Detail
-
matches
public boolean matches(java.lang.String sourceName, java.lang.Object templateSource) throws java.io.IOException
- Throws:
java.io.IOException
-
isCaseInsensitive
public boolean isCaseInsensitive()
-
setCaseInsensitive
public void setCaseInsensitive(boolean caseInsensitive)
Sets if the matching will be case insensitive (UNICODE compliant); default isfalse
.
-
caseInsensitive
public PathGlobMatcher caseInsensitive(boolean caseInsensitive)
Fluid API variation ofsetCaseInsensitive(boolean)
-
-