Package org.eclipse.jface.text
Class MultiStringMatcher
java.lang.Object
org.eclipse.jface.text.MultiStringMatcher
Fast matcher to find the occurrences of any of a fixed set of constant strings. Supports finding
all (possibly overlapping) matches, or only the leftmost longest match.
- Since:
- 3.9
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA Builder for creating aMultiStringMatcher.static interfaceDescribes a match result ofindexOf(CharSequence, int), giving access to the matched string and the offset in the text it was matched at. -
Method Summary
Modifier and TypeMethodDescriptionstatic MultiStringMatcher.Builderbuilder()Creates an initially emptyMultiStringMatcher.Builder.static MultiStringMatcherCreates aMultiStringMatcherfor the givensearchStrings.find(CharSequence text, int offset) Finds all occurrences of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset, including overlapping occurrences.voidfind(CharSequence text, int offset, Consumer<MultiStringMatcher.Match> matches) Finds all occurrences of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset, including overlapping occurrences.indexOf(CharSequence text, int offset) Find the next occurrence of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset.static MultiStringMatcher.MatchindexOf(CharSequence text, int offset, String... searchStrings) Finds the leftmost longest occurrence of any of the givensearchStringsin thetextstarting at the givenoffset.
-
Method Details
-
builder
Creates an initially emptyMultiStringMatcher.Builder.- Returns:
- the
MultiStringMatcher.Builder
-
find
Finds all occurrences of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset, including overlapping occurrences.- Parameters:
text- to search (notnull)offset- to start searching atmatches-Consumerall matches are fed to- Since:
- 3.10
-
find
Finds all occurrences of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset, including overlapping occurrences.- Parameters:
text- to search (notnull)offset- to start searching at- Returns:
- a possibly empty list of matches
-
indexOf
Find the next occurrence of any of the search strings of theMultiStringMatcherin the giventextstarting at the givenoffset.Performs a simultaneous search for all the strings, returning the leftmost match. If multiple search strings match at the same index, the longest match is returned.
- Parameters:
text- to search (notnull)offset- to start searching at- Returns:
- the leftmost longest match found, or
nullif no match was found.
-
indexOf
public static MultiStringMatcher.Match indexOf(CharSequence text, int offset, String... searchStrings) Finds the leftmost longest occurrence of any of the givensearchStringsin thetextstarting at the givenoffset.To match the same set of search strings repeatedly against texts it is more efficient to build and re-use a
MultiStringMatcher.- Parameters:
text- to search (notnull)offset- to start searching atsearchStrings- to look for; non-nulland non-empty strings are ignored- Returns:
- a
MultiStringMatcher.Matchdescribing the match found, ornullif no match was found or there are no non-nullnon-emptysearchStrings
-
create
Creates aMultiStringMatcherfor the givensearchStrings.If there are no non-
nullnon-emptysearchStrings, the returnedMultiStringMatcherwill never match anything.- Parameters:
searchStrings- to look for; non-nulland non-empty strings are ignored- Returns:
- the
MultiStringMatcher
-