Package org.apache.felix.gogo.runtime
Class GlobPathMatcher
- java.lang.Object
-
- org.apache.felix.gogo.runtime.GlobPathMatcher
-
public class GlobPathMatcher extends java.lang.ObjectFreely adapted from Spring's AntPathMatcher. We don't use the file system's glob PathMatcher because it can't detect directories which can't be a start of a match.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancaseSensitivestatic java.lang.StringDEFAULT_PATH_SEPARATORDefault path separator: "/"private java.lang.StringpathSeparatorprivate java.lang.String[]pattDirsprivate java.lang.Stringpatternprivate java.util.regex.Pattern[]pattPats
-
Constructor Summary
Constructors Constructor Description GlobPathMatcher(java.lang.String pattern)Create a new instance with theDEFAULT_PATH_SEPARATOR.GlobPathMatcher(java.lang.String pattern, java.lang.String pathSeparator, boolean caseSensitive)A convenient, alternative constructor to use with a custom path separator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.regex.PatterncreateMatcherPattern(java.lang.String pattern)booleanmatches(java.lang.String path, boolean fullMatch)Actually match the givenpathagainst the givenpattern.private booleanmatchStrings(int pattIdx, java.lang.String str)private java.lang.String[]tokenizePath(java.lang.String path)Tokenize the given path String into parts, based on this matcher's settings.
-
-
-
Field Detail
-
DEFAULT_PATH_SEPARATOR
public static final java.lang.String DEFAULT_PATH_SEPARATOR
Default path separator: "/"- See Also:
- Constant Field Values
-
pattern
private java.lang.String pattern
-
pathSeparator
private java.lang.String pathSeparator
-
caseSensitive
private boolean caseSensitive
-
pattDirs
private java.lang.String[] pattDirs
-
pattPats
private java.util.regex.Pattern[] pattPats
-
-
Constructor Detail
-
GlobPathMatcher
public GlobPathMatcher(java.lang.String pattern)
Create a new instance with theDEFAULT_PATH_SEPARATOR.- Parameters:
pattern- the pattern
-
GlobPathMatcher
public GlobPathMatcher(java.lang.String pattern, java.lang.String pathSeparator, boolean caseSensitive)A convenient, alternative constructor to use with a custom path separator.- Parameters:
pattern- the patternpathSeparator- the path separator to use, must not benull.caseSensitive- is case sensitive
-
-
Method Detail
-
matches
public boolean matches(java.lang.String path, boolean fullMatch)Actually match the givenpathagainst the givenpattern.- Parameters:
path- the path String to testfullMatch- whether a full pattern match is required (else a pattern match as far as the given base path goes is sufficient)- Returns:
trueif the suppliedpathmatched,falseif it didn't
-
tokenizePath
private java.lang.String[] tokenizePath(java.lang.String path)
Tokenize the given path String into parts, based on this matcher's settings.- Parameters:
path- the path to tokenize- Returns:
- the tokenized path parts
-
matchStrings
private boolean matchStrings(int pattIdx, java.lang.String str)
-
createMatcherPattern
private java.util.regex.Pattern createMatcherPattern(java.lang.String pattern)
-
-