public final class SearchRequest extends AbstractCharSequenceSearchRequest
setSearchStrings(String[])
) and specifying the Page
s to
search in (AbstractCharSequenceSearchRequest.setPages(List)
). These settings are mandatory. As a addition there are three
optional settings: case sensitive (setCaseSensitive(boolean)
), whole words only (
setWholeWordsOnly(boolean)
) and (setWildcard(boolean)
). To check if the
SearchRequest
is valid, the isValid()
method can be invoked which will return
true
in case of a valid configuration.SearchStateChangeEvent
:
SearchStateChangeEvent.isRunning()
SearchStateChangeEvent.isRunning()
SearchStateChangeEvent.isCancelled()
SearchStateChangeEvent.isFinished()
AbstractCharSequenceSearchRequest.execute()
method.
Now the internal mechanism will be called and starts to process the request. All results and
status changes will be made available using the listener interfaces described above.SearchRequest
implements the VetoableChangeListener
-support. That means that
for all possible properties, a VetoableChangeListener
can be registered. Possible
properties are: PROPERTY_CASE_SENSITIVE
, AbstractCharSequenceSearchRequest.PROPERTY_PAGES
,
PROPERTY_SEARCHSTRINGS
, PROPERTY_WHOLE_WORDS_ONLY
and
PROPERTY_WILDCARD
. The methods used to set those properties are shown at the property
declaration. Modifier and Type | Class and Description |
---|---|
static class |
SearchRequest.SearchState |
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_CASE_SENSITIVE
case sensitive searching property.
|
static String |
PROPERTY_SEARCHSTRINGS
search strings property
|
static String |
PROPERTY_WHOLE_WORDS_ONLY
whole words only property
|
static String |
PROPERTY_WILDCARD
wildcard property
|
PROPERTY_PAGES
Constructor and Description |
---|
SearchRequest() |
Modifier and Type | Method and Description |
---|---|
protected CharSequenceMatcher |
createMatcher()
Creates a
CharSequenceMatcher . |
String[] |
getSearchStrings()
the search strings that have been specified using the
setSearchStrings(String[])
method. |
boolean |
isCaseSensitive() |
boolean |
isValid()
Checks if the configuration of the
SearchRequest is sufficient. |
boolean |
isWholeWordsOnly() |
boolean |
isWildcard() |
void |
setCaseSensitive(boolean enable)
Specifies whether it should be searched in a case sensitive manner or not.
|
void |
setSearchStrings(String[] searchStrings)
specifies the strings for which the text search should search for.
|
void |
setWholeWordsOnly(boolean enable)
Specifies wether it should be searched for whole words only or not.
|
void |
setWildcard(boolean enable)
Specifies whether it should be searched with wildcards or not.
|
addSearchStateListener, cancel, ensureModifiable, ensureNotRunning, ensureValid, execute, executeSync, getInternalHook, getPages, getResultList, getState, isModifiable, isRunning, removeSearchStateListener, reset, setPages
public static final String PROPERTY_CASE_SENSITIVE
setCaseSensitive(boolean)
,
Constant Field Valuespublic static final String PROPERTY_SEARCHSTRINGS
setSearchStrings(String[])
,
Constant Field Valuespublic static final String PROPERTY_WHOLE_WORDS_ONLY
setWholeWordsOnly(boolean)
,
Constant Field Valuespublic static final String PROPERTY_WILDCARD
setWildcard(boolean)
,
Constant Field Valuespublic String[] getSearchStrings()
setSearchStrings(String[])
method.setSearchStrings(String[])
setSearchStrings(String[])
public boolean isCaseSensitive()
true
if the SearchRequest
is configured for case sensitive
searchingsetCaseSensitive(boolean)
public boolean isValid()
SearchRequest
is sufficient. It will be sufficient
if the the searchStrings (using the setSearchStrings(String[])
method) and the pages
(using the AbstractCharSequenceSearchRequest.setPages(List)
method) have been set.isValid
in class AbstractCharSequenceSearchRequest
true
if the configuration is sufficientAbstractCharSequenceSearchRequest.isValid()
public boolean isWholeWordsOnly()
true
if the SearchRequest
is configured for whole words only
searchingsetWholeWordsOnly(boolean)
public boolean isWildcard()
true
if the SearchRequest
is configured for wildcard
searchingsetWildcard(boolean)
public void setCaseSensitive(boolean enable)
String
s specified using setSearchStrings(String[])
.
Examples:
search string | text in page | matches (case sensitive) |
---|---|---|
Levigo |
levigo |
no |
MO:DCA |
MO:DCA |
yes |
MO:dca |
MO:DCA |
no |
NOTE:
Please keep in Mind that settings using this method will only be possible if the request is
modifiable. If the SearchRequest
is not modifiable this method will throw a
IllegalStateException
. For details about the modifiable state of the
SearchRequest
, please see AbstractCharSequenceSearchRequest.isModifiable()
enable
- set to true
if search should be case sensitive.IllegalStateException
- if the search request is not modifiable (see
AbstractCharSequenceSearchRequest.isModifiable()
public void setSearchStrings(String[] searchStrings)
String
s beeing
specified will be interpreted as a logical or
. That means that the text search
will search for searchString[0] ... searchString[n]
independent from each other.
NOTE:
Please keep in Mind that settings using this method will only be possible if the request is
modifiable. If the SearchRequest
is not modifiable this method will throw a
IllegalStateException
. For details about the modifiable state of the
SearchRequest
, please see AbstractCharSequenceSearchRequest.isModifiable()
searchStrings
- an array of String
s to search for.IllegalArgumentException
- if the searchStrings are null or an array with a size of zeroIllegalStateException
- if the search request is not modifiable (see
AbstractCharSequenceSearchRequest.isModifiable()
public void setWholeWordsOnly(boolean enable)
Examples: (spaces will be represented as underscore (_) characters)
search string | text in page | matches |
---|---|---|
ja |
_jadice_ |
no |
jadice |
_jadice_ |
yes |
MO:dca |
_MO:DCA_ |
yes |
NOTE:
Please keep in Mind that settings using this method will only be possible if the request is
modifiable. If the SearchRequest
is not modifiable this method will throw a
IllegalStateException
. For details about the modifiable state of the
SearchRequest
, please see AbstractCharSequenceSearchRequest.isModifiable()
enable
- set to true
if the text search should search for whole words only.IllegalStateException
- if the search request is not modifiable (see
AbstractCharSequenceSearchRequest.isModifiable()
public void setWildcard(boolean enable)
Examples:
search string | text in page | matches |
---|---|---|
ja*go |
jadice_by_levigo |
yes |
jadice_?.5 |
jadice_5.5 |
yes |
jadice?.5 |
jadice_?.5 |
no |
jadice_\?.5 |
jadice_?.5 |
yes |
NOTE:
Please keep in mind that settings using this method will only be possible if the request is
modifiable. If the SearchRequest
is not modifiable this method will throw a
IllegalStateException
. For details about the modifiable state of the
SearchRequest
, please see AbstractCharSequenceSearchRequest.isModifiable()
enable
- set to true
if the text search should search for wildcard.IllegalStateException
- if the search request is not modifiable (see
AbstractCharSequenceSearchRequest.isModifiable()
protected CharSequenceMatcher createMatcher()
AbstractCharSequenceSearchRequest
CharSequenceMatcher
. This method may never return null.createMatcher
in class AbstractCharSequenceSearchRequest
CharSequenceMatcher
Copyright © 2024 levigo holding gmbh. All rights reserved.