public class

StarMatcher

extends Object
implements IStringMatcher
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.base.StarMatcher

Class Overview

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".

Summary

Nested Classes
class StarMatcher.Result String match result provided by the find method. 
Public Constructors
StarMatcher(String searchPattern, boolean caseInsensitive, boolean useEscapes)
Create a matcher.
StarMatcher(String searchPattern)
Create a case-insensitive matcher that supports escape sequences.
Public Methods
Collection<String> collect(Collection<String> values)
Collect all matches.
StarMatcher.Result find(String buffer, int fromIndex)
Search for a match in the provided buffer.
int getCharSearchLength()
Retrieve the minimum number of characters contained in substrings matched by this matcher.
boolean matches(String value)
Attempt to find the search string inside the provided buffer.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.util.base.IStringMatcher

Public Constructors

public StarMatcher (String searchPattern, boolean caseInsensitive, boolean useEscapes)

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 \x
caseInsensitive true to conduct case-insensitive searches
useEscapes 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

public StarMatcher (String searchPattern)

Create a case-insensitive matcher that supports escape sequences.

Parameters
searchPattern search string (see StarMatcher(String, boolean, boolean))

Public Methods

public Collection<String> collect (Collection<String> values)

Collect all matches.

Parameters
values candidate values
Returns
  • collection of values that matched

public StarMatcher.Result find (String buffer, int fromIndex)

Search for a match in the provided buffer.

Parameters
buffer text to be searched
fromIndex start index in the buffer
Returns
  • an object or null if nothing was found

public int getCharSearchLength ()

Retrieve the minimum number of characters contained in substrings matched by this matcher.

public boolean matches (String value)

Attempt to find the search string inside the provided buffer. This method returns true if the search string is found.

Parameters
value buffer to be matched
Returns
  • true if it is a match