public class GlobPattern
extends java.lang.Object
As we are expecting to compile a pattern once and execute matches multiple times care has been taken to move as much of the pattern processing to the compile phase.
When a pattern is compiled all the case sensitivity is handled, wildcard and match one characters are tagged in separate boolean lookup arrays and multiple wildcards are folded into one. Also all escape handling is processed so the matching engine has to do as little work as possible.
Some compiled pattern examples Example 1: pattern = "foo%bar" will compile to lowerCase = "foo%bar" upperCase = "FOO%BAR" wildcard = "0001000" matchOne = "0000000" Example 2: pattern = "foo%%bar" will compile to lowerCase = "foo%bar" upperCase = "FOO%BAR" wildcard = "0001000" matchOne = "0000000" Example 3: pattern = "foo%%\%%%_\_bar" will compile to lowerCase = "foo%%%__bar" upperCase = "FOO%%%__BAR" wildcard = "00010100000" matchOne = "00000010000"
| Modifier and Type | Field and Description |
|---|---|
static int |
CASE_INSENSITIVE
Instructs the matcher to do case-insensitive comparisons.
|
static int |
HANDLE_ESCAPES
Instructs the compiler to handle escape sequences like \% \n and \t.
|
static char |
NULL_CHARACTER
If the null character is specified as either the wildcard or match-one character then that feature will
be disabled.
|
| Modifier and Type | Method and Description |
|---|---|
static MatchingEngine |
compile(java.lang.String globPattern)
Compile the given glob string using '*' for the wildcard and '?' for the match one character.
|
static MatchingEngine |
compile(java.lang.String globPattern,
char wildcardChar,
char matchOneChar,
int flags)
Compile the given glob pattern and return a GlobPattern Matching.
|
public static final char NULL_CHARACTER
public static final int CASE_INSENSITIVE
public static final int HANDLE_ESCAPES
public static MatchingEngine compile(java.lang.String globPattern)
The returned matching engine is thread safe.
globPattern - The glob pattern to compilepublic static MatchingEngine compile(java.lang.String globPattern, char wildcardChar, char matchOneChar, int flags)
The returned matching engine is thread safe.
globPattern - The glob pattern to compilewildcardChar - The character to use for the wildcard, matching zero or more.
Typically Unix uses '*' while SQL uses '%'.
To turn this feature off pass in the null '\0' character.matchOneChar - The character to use for matching one. Typically Unix uses '?' while SQL uses '_'.
To turn this feature off pass in the null '\0' character.flags - Match flags, a bit mask that may include CASE_INSENSITIVE and HANDLE_ESCAPESjava.lang.IllegalArgumentException - If the globPattern is null.