Top Description Fields Constructors Methods
org.hsqldb.lib

public Class ScannerSearchAlgorithm

extends Object
Class Inheritance
Imports
java.io.Reader, java.util.Scanner, java.util.logging.Logger, java.util.regex.Pattern, .PatternSyntaxException

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

Field Summary

Modifier and TypeField and Description
private static final Logger
public static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static long

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.
search
(Reader
to search
reader
,
char[]
to find
searchstr
,
boolean
true to treat searchstr as a literal search term; false to treat searchstr as a regular expression.
literal
)

the given reader for the given searchstr.

public static long

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.
search
(Reader
to search
reader
,
String
to find
searchstr
,
boolean
true to treat searchstr as a literal search term; false to treat searchstr as a regular expression.
literal
)

the given reader for the given searchstr.

public static long

Returns:

zero-based offset into stream at which searchstr is found; -1 if not found;
search
(Reader
to search
reader
,
Pattern
to find
pattern
)

the given reader for the given pattern.

private static long

Returns:

zero-based offset into stream at which searchstr is found; -1 if not found;
searchNoChecks
(Reader
to search
reader
,
Pattern
to find
pattern
)

the given reader for the given pattern.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
SUGGESTED_MAX_LITERAL_SIZEback to summary
public static final int SUGGESTED_MAX_LITERAL_SIZE

is 1024. This is the size above which it may be better to use KMPSearchAlgorithm.

Constructor Detail

ScannerSearchAlgorithmback to summary
private ScannerSearchAlgorithm()

Method Detail

searchback to summary
public static long search(Reader reader, char[] searchstr, boolean literal)

the given reader for the given searchstr.

Parameters
reader:Reader

to search

searchstr:char[]

to find

literal:boolean

true to treat searchstr as a literal search term; false to treat searchstr as a regular expression.

Returns:long

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.

Exceptions
IllegalStateException:
if a Scanner illegal state occurs
IllegalArgumentException:
if a Scanner illegal argument is encountered.
searchback to summary
public static long search(Reader reader, String searchstr, boolean literal) throws NullPointerException, PatternSyntaxException, IllegalStateException, IllegalArgumentException

the given reader for the given searchstr.

Parameters
reader:Reader

to search

searchstr:String

to find

literal:boolean

true to treat searchstr as a literal search term; false to treat searchstr as a regular expression.

Returns:long

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.

Exceptions
PatternSyntaxException:
if searchstr expression's syntax is invalid
IllegalStateException:
if a Scanner illegal state occurs
IllegalArgumentException:
if a Scanner illegal argument is encountered.
searchback to summary
public static long search(Reader reader, Pattern pattern) throws IllegalStateException, IllegalArgumentException

the given reader for the given pattern.

Parameters
reader:Reader

to search

pattern:Pattern

to find

Returns:long

zero-based offset into stream at which searchstr is found; -1 if not found;

Exceptions
IllegalStateException:
if a Scanner illegal state occurs
IllegalArgumentException:
if a Scanner illegal argument is encountered.
NullPointerException:
if reader is null or pattern is null.
searchNoChecksback to summary
private static long searchNoChecks(Reader reader, Pattern pattern) throws IllegalStateException, IllegalArgumentException

the given reader for the given pattern.

Parameters
reader:Reader

to search

pattern:Pattern

to find

Returns:long

zero-based offset into stream at which searchstr is found; -1 if not found;

Exceptions
IllegalStateException:
if a Scanner illegal state occurs
IllegalArgumentException:
if a Scanner illegal argument is encountered.