java.lang.Object
org.hsqldb.lib.ScannerSearchAlgorithm
Provides a string search facility using a
Scanner
.- Since:
- 2.7.x
- Author:
- Campbell Burnet (campbell-burnet@users dot sourceforge.net)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic long
the givenreader
for the givensearchstr
.static long
the givenreader
for the givensearchstr
.static long
the givenreader
for the givenpattern
.
-
Field Details
-
SUGGESTED_MAX_LITERAL_SIZE
public static final int SUGGESTED_MAX_LITERAL_SIZEis 1024. This is the size above which it may be better to useKMPSearchAlgorithm
.- See Also:
-
-
Method Details
-
search
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:
IllegalStateException
- if aScanner
illegal state occursIllegalArgumentException
- if aScanner
illegal argument is encountered.
-
search
public static long search(Reader reader, String searchstr, boolean literal) throws NullPointerException, PatternSyntaxException, IllegalStateException, 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:
PatternSyntaxException
- ifsearchstr
expression's syntax is invalidIllegalStateException
- if aScanner
illegal state occursIllegalArgumentException
- if aScanner
illegal argument is encountered.NullPointerException
-
search
public static long search(Reader reader, Pattern pattern) throws IllegalStateException, 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:
NullPointerException
- ifreader
is null orpattern
is null.IllegalStateException
- if aScanner
illegal state occursIllegalArgumentException
- if aScanner
illegal argument is encountered.
-