- java.lang.Object
-
- org.hsqldb.lib.ScannerSearchAlgorithm
-
public class ScannerSearchAlgorithm extends java.lang.Object
Provides a string search facility using aScanner
.- 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 givenreader
for the givensearchstr
.static long
search(java.io.Reader reader, java.lang.String searchstr, boolean literal)
the givenreader
for the givensearchstr
.static long
search(java.io.Reader reader, java.util.regex.Pattern pattern)
the givenreader
for the givenpattern
.
-
-
-
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 useKMPSearchAlgorithm
.- See Also:
- Constant Field Values
-
-
Method Detail
-
search
public static long search(java.io.Reader reader, char[] searchstr, boolean literal)
the givenreader
for the givensearchstr
.- Parameters:
reader
- to searchsearchstr
- to findliteral
- true to treatsearchstr
as a literal search term; false to treatsearchstr
as a regular expression.- Returns:
- zero-based offset into stream at which
searchstr
is found; -1 if not found,reader
is null, orsearchstr
is null; 0 ifsearchstr.length() == 0 && literal == true
. - Throws:
java.lang.IllegalStateException
- if aScanner
illegal state occursjava.lang.IllegalArgumentException
- if aScanner
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 givenreader
for the givensearchstr
.- Parameters:
reader
- to searchsearchstr
- to findliteral
- true to treatsearchstr
as a literal search term; false to treatsearchstr
as a regular expression.- Returns:
- zero-based offset into stream at which
searchstr
is found; -1 if not found,reader
is null, orsearchstr
is null; 0 ifsearchstr.length() == 0 && literal == true
. - Throws:
java.util.regex.PatternSyntaxException
- ifsearchstr
expression's syntax is invalidjava.lang.IllegalStateException
- if aScanner
illegal state occursjava.lang.IllegalArgumentException
- if aScanner
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 givenreader
for the givenpattern
.- Parameters:
reader
- to searchpattern
- to find- Returns:
- zero-based offset into stream at which
searchstr
is found; -1 if not found; - Throws:
java.lang.NullPointerException
- ifreader
is null orpattern
is null.java.lang.IllegalStateException
- if aScanner
illegal state occursjava.lang.IllegalArgumentException
- if aScanner
illegal argument is encountered.
-
-