Class StarMatcher

java.lang.Object
com.pnfsoftware.jeb.util.base.StarMatcher
All Implemented Interfaces:
IStringMatcher

public class StarMatcher extends Object implements 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".
  • Constructor Details

    • StarMatcher

      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
    • StarMatcher

      public StarMatcher(String searchPattern)
      Create a case-insensitive matcher that supports escape sequences.
      Parameters:
      searchPattern - search string (see StarMatcher(String, boolean, boolean))
  • Method Details

    • getCharSearchLength

      public int getCharSearchLength()
      Retrieve the minimum number of characters contained in substrings matched by this matcher.
      Returns:
    • matches

      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.
      Specified by:
      matches in interface IStringMatcher
      Parameters:
      value - buffer to be matched
      Returns:
      true if it is a match
    • collect

      public Collection<String> collect(Collection<String> values)
      Collect all matches.
      Parameters:
      values - candidate values
      Returns:
      collection of values that matched
    • find

      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