Package com.pnfsoftware.jeb.util.base
Class StarMatcher
java.lang.Object
com.pnfsoftware.jeb.util.base.StarMatcher
- All Implemented Interfaces:
IStringMatcher
A string matcher accepting wildcard-expressions
* (any number of chars) and ?
(any one char). An initial star is implied to allow matching anywhere in the expression. E.g.:
"blah*foo" will match "xxxblahyyyfoo".-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classString match result provided by thefindmethod. -
Constructor Summary
ConstructorsConstructorDescriptionStarMatcher(String searchPattern) Create a case-insensitive matcher that supports escape sequences.StarMatcher(String searchPattern, boolean caseInsensitive, boolean useEscapes) Create a matcher. -
Method Summary
Modifier and TypeMethodDescriptioncollect(Collection<String> values) Collect allmatches.Search for a match in the provided buffer.intRetrieve the minimum number of characters contained in substrings matched by this matcher.booleanAttempt to find the search string inside the provided buffer.
-
Constructor Details
-
StarMatcher
Create a matcher.- Parameters:
searchPattern- search string; may contain*(any number of chars) or?(any single char); a leading star is implied by the search routines;*and?cannot be used as the search string header, i.e. they will be silently discarded if found before any actual character sequence; to use*and?as actual characters to be searched, escape them with \; other usual escapes (\r, \n, \t, \', \") can be used; unknown escape sequences will simply be treated as normal character sequences \xcaseInsensitive- true to conduct case-insensitive searchesuseEscapes- true to allow the escape of special characters question mark, star, as well as CR, LF, TAB, single-quote, double-quote, and backslash, with a backslash character
-
StarMatcher
Create a case-insensitive matcher that supports escape sequences.- Parameters:
searchPattern- search string (seeStarMatcher(String, boolean, boolean))
-
-
Method Details
-
getCharSearchLength
public int getCharSearchLength()Retrieve the minimum number of characters contained in substrings matched by this matcher.- Returns:
-
matches
Attempt to find the search string inside the provided buffer. This method returns true if the search string is found.- Specified by:
matchesin interfaceIStringMatcher- Parameters:
value- buffer to be matched- Returns:
- true if it is a match
-
collect
Collect allmatches.- Parameters:
values- candidate values- Returns:
- collection of values that matched
-
find
Search for a match in the provided buffer.- Parameters:
buffer- text to be searchedfromIndex- start index in the buffer- Returns:
- an object or null if nothing was found
-