Module org.hsqldb
Package org.hsqldb.lib

## Class ScannerSearchAlgorithm

- java.lang.Object
- - org.hsqldb.lib.ScannerSearchAlgorithm

-     public class ScannerSearchAlgorithm
      extends java.lang.Object

  Provides a string search facility using a `Scanner`.
  Since:
    2.7.x
  Author:
    Campbell Burnet (campbell-burnet@users dot sourceforge.net)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `SUGGESTED_MAX_LITERAL_SIZE` | is 1024.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static long` | `search​(java.io.Reader reader, char[] searchstr, boolean literal)` | the given `reader` for the given `searchstr`.
    `static long` | `search​(java.io.Reader reader, java.lang.String searchstr, boolean literal)` | the given `reader` for the given `searchstr`.
    `static long` | `search​(java.io.Reader reader, java.util.regex.Pattern pattern)` | the given `reader` for the given `pattern`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SUGGESTED_MAX_LITERAL_SIZE

          public static final int SUGGESTED_MAX_LITERAL_SIZE

      is 1024. This is the size above which it may be better to use `KMPSearchAlgorithm`.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### search

          public static long search​(java.io.Reader reader,
                                    char[] searchstr,
                                    boolean literal)

      the given `reader` for the given `searchstr`.
      Parameters:
        `reader` - to search
        `searchstr` - to find
        `literal` - true to treat `searchstr` as a literal search term; false to treat `searchstr` as a regular expression.
      Returns:
        zero-based offset into stream at which `searchstr` is found; -1 if not found, `reader` is null, or `searchstr` is null; 0 if `searchstr.length() == 0 && literal == true`.
      Throws:
        `java.lang.IllegalStateException` - if a `Scanner` illegal state occurs
        `java.lang.IllegalArgumentException` - if a `Scanner` illegal argument is encountered.

    - #### search

          public static long search​(java.io.Reader reader,
                                    java.lang.String searchstr,
                                    boolean literal)
                             throws java.lang.NullPointerException,
                                    java.util.regex.PatternSyntaxException,
                                    java.lang.IllegalStateException,
                                    java.lang.IllegalArgumentException

      the given `reader` for the given `searchstr`.
      Parameters:
        `reader` - to search
        `searchstr` - to find
        `literal` - true to treat `searchstr` as a literal search term; false to treat `searchstr` as a regular expression.
      Returns:
        zero-based offset into stream at which `searchstr` is found; -1 if not found, `reader` is null, or `searchstr` is null; 0 if `searchstr.length() == 0 && literal == true`.
      Throws:
        `java.util.regex.PatternSyntaxException` - if `searchstr` expression's syntax is invalid
        `java.lang.IllegalStateException` - if a `Scanner` illegal state occurs
        `java.lang.IllegalArgumentException` - if a `Scanner` illegal argument is encountered.
        `java.lang.NullPointerException`

    - #### search

          public static long search​(java.io.Reader reader,
                                    java.util.regex.Pattern pattern)
                             throws java.lang.IllegalStateException,
                                    java.lang.IllegalArgumentException

      the given `reader` for the given `pattern`.
      Parameters:
        `reader` - to search
        `pattern` - to find
      Returns:
        zero-based offset into stream at which `searchstr` is found; -1 if not found;
      Throws:
        `java.lang.NullPointerException` - if `reader` is null or `pattern` is null.
        `java.lang.IllegalStateException` - if a `Scanner` illegal state occurs
        `java.lang.IllegalArgumentException` - if a `Scanner` illegal argument is encountered.