public class FileNameMatcher
extends java.lang.Object
Supported are the wildcard characters * and ? and groups with:
Modifier and Type | Field and Description |
---|---|
private static java.util.regex.Pattern |
characterClassStartPattern |
(package private) static java.util.List<Head> |
EMPTY_HEAD_LIST |
private java.util.List<Head> |
heads |
private java.util.List<Head> |
headsStartValue |
private java.util.List<Head> |
listForLocalUseage
{
extendStringToMatchByOneCharacter(char) needs a list for the
new heads, allocating a new array would be bad for the performance, as
the method gets called very often. |
Modifier | Constructor and Description |
---|---|
|
FileNameMatcher(FileNameMatcher other)
A Copy Constructor which creates a new
FileNameMatcher with the same state and
reset point like other . |
private |
FileNameMatcher(java.util.List<Head> headsStartValue) |
private |
FileNameMatcher(java.util.List<Head> headsStartValue,
java.util.List<Head> heads) |
|
FileNameMatcher(java.lang.String patternString,
java.lang.Character invalidWildgetCharacter)
Constructor for FileNameMatcher
|
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.String stringToMatch)
Append to the string which is matched against the patterns of this class
|
boolean |
canAppendMatch()
Whether a match can be appended
|
private static java.util.List<Head> |
createHeadsStartValues(java.lang.String patternString,
java.lang.Character invalidWildgetCharacter) |
FileNameMatcher |
createMatcherForSuffix()
Create a
FileNameMatcher instance which
uses the same pattern like this matcher, but has the current state of
this matcher as reset and start point |
private static java.util.List<AbstractHead> |
createSimpleHeads(java.lang.String patternPart,
java.lang.Character invalidWildgetCharacter) |
private static AbstractHead |
createWildCardHead(java.lang.Character invalidWildgetCharacter,
boolean star) |
private boolean |
extendStringToMatchByOneCharacter(char c) |
private static int |
findGroupEnd(int indexOfStartBracket,
java.lang.String pattern) |
private static int |
indexOfUnescaped(java.lang.String searchString,
char ch,
int fromIndex) |
boolean |
isMatch()
Whether the matcher matches
|
private static java.util.List<AbstractHead> |
parseHeads(java.lang.String pattern,
java.lang.Character invalidWildgetCharacter) |
void |
reset()
Resets this matcher to it's state right after construction.
|
static final java.util.List<Head> EMPTY_HEAD_LIST
private static final java.util.regex.Pattern characterClassStartPattern
private java.util.List<Head> headsStartValue
private java.util.List<Head> heads
private java.util.List<Head> listForLocalUseage
extendStringToMatchByOneCharacter(char)
needs a list for the
new heads, allocating a new array would be bad for the performance, as
the method gets called very often.private FileNameMatcher(java.util.List<Head> headsStartValue)
headsStartValue
- must be a list which will never be modified.private FileNameMatcher(java.util.List<Head> headsStartValue, java.util.List<Head> heads)
headsStartValue
- must be a list which will never be modified.heads
- a list which will be cloned and then used as current head
list.public FileNameMatcher(java.lang.String patternString, java.lang.Character invalidWildgetCharacter) throws InvalidPatternException
patternString
- must contain a pattern which fnmatch would accept.invalidWildgetCharacter
- if this parameter isn't null then this character will not
match at wildcards(* and ? are wildcards).InvalidPatternException
- if the patternString contains a invalid fnmatch pattern.public FileNameMatcher(FileNameMatcher other)
FileNameMatcher
with the same state and
reset point like other
.other
- another FileNameMatcher
instance.private static java.util.List<Head> createHeadsStartValues(java.lang.String patternString, java.lang.Character invalidWildgetCharacter) throws InvalidPatternException
InvalidPatternException
private static int findGroupEnd(int indexOfStartBracket, java.lang.String pattern) throws InvalidPatternException
InvalidPatternException
private static java.util.List<AbstractHead> parseHeads(java.lang.String pattern, java.lang.Character invalidWildgetCharacter) throws InvalidPatternException
InvalidPatternException
private static java.util.List<AbstractHead> createSimpleHeads(java.lang.String patternPart, java.lang.Character invalidWildgetCharacter)
private static AbstractHead createWildCardHead(java.lang.Character invalidWildgetCharacter, boolean star)
private boolean extendStringToMatchByOneCharacter(char c)
c
- new character to appendprivate static int indexOfUnescaped(java.lang.String searchString, char ch, int fromIndex)
public void append(java.lang.String stringToMatch)
stringToMatch
- extends the string which is matched against the patterns of
this class.public void reset()
public FileNameMatcher createMatcherForSuffix()
FileNameMatcher
instance which
uses the same pattern like this matcher, but has the current state of
this matcher as reset and start pointFileNameMatcher
instance which
uses the same pattern like this matcher, but has the current
state of this matcher as reset and start point.public boolean isMatch()
public boolean canAppendMatch()