com.levigo.jadice.search
Class SearchRequest

java.lang.Object
  extended by com.levigo.jadice.search.AbstractCharSequenceSearchRequest
      extended by com.levigo.jadice.search.SearchRequest

public final class SearchRequest
extends AbstractCharSequenceSearchRequest

provides a interaction interface for searching and retrieving results. The SearchRequest is the way to access the text searching functionality of the levigo jadice viewer. Working with this class has the following main aspects:

  1. configuring the request:
    this is the most important part of the interaction. The configuration includes setting the strings to search for (setSearchStrings(String[])) and specifying the Pages to search in (AbstractCharSequenceSearchRequest.setPages(List)). These settings are mandatory. As a addition there are two optional settings: case sensitive (setCaseSensitive(boolean)) and whole words only ( setWholeWordsOnly(boolean)). To check if the SearchRequest is valid, the isValid() method can be invoked witch will return true in case of a valid configuration.
  2. configuring notification:
    SearchStateChangeEvent:
  3. executing the request:
    After the configuration, the request is ready to be executed using the 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.
  4. advanced settings:
    The 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 and PROPERTY_WHOLE_WORDS_ONLY. The methods used to set those properties are shown at the property declaration.


Nested Class Summary
static class SearchRequest.SearchState
           
 
Field Summary
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
 
Fields inherited from class com.levigo.jadice.search.AbstractCharSequenceSearchRequest
PROPERTY_PAGES
 
Constructor Summary
SearchRequest()
           
 
Method Summary
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()
           
 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.
 
Methods inherited from class com.levigo.jadice.search.AbstractCharSequenceSearchRequest
addSearchStateListener, cancel, ensureModifiable, ensureNotRunning, ensureValid, execute, executeSync, getInternalHook, getPages, getResultList, getState, isModifiable, isRunning, reset, setPages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_CASE_SENSITIVE

public static final String PROPERTY_CASE_SENSITIVE
case sensitive searching property.

See Also:
setCaseSensitive(boolean), Constant Field Values

PROPERTY_SEARCHSTRINGS

public static final String PROPERTY_SEARCHSTRINGS
search strings property

See Also:
setSearchStrings(String[]), Constant Field Values

PROPERTY_WHOLE_WORDS_ONLY

public static final String PROPERTY_WHOLE_WORDS_ONLY
whole words only property

See Also:
setWholeWordsOnly(boolean), Constant Field Values
Constructor Detail

SearchRequest

public SearchRequest()
Method Detail

getSearchStrings

public String[] getSearchStrings()
the search strings that have been specified using the setSearchStrings(String[]) method.

Returns:
the search strings that have been specified using setSearchStrings(String[])
See Also:
setSearchStrings(String[])

isCaseSensitive

public boolean isCaseSensitive()
Returns:
true if the SearchRequest is configured for case sensitive searching
See Also:
setCaseSensitive(boolean)

isValid

public boolean isValid()
Checks if the configuration of the 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.

Overrides:
isValid in class AbstractCharSequenceSearchRequest
Returns:
true if the configuration is sufficient
See Also:
AbstractCharSequenceSearchRequest.isValid()

isWholeWordsOnly

public boolean isWholeWordsOnly()
Returns:
true if the SearchRequest is configured for whole words only searching
See Also:
setWholeWordsOnly(boolean)

setCaseSensitive

public void setCaseSensitive(boolean enable)
Specifies whether it should be searched in a case sensitive manner or not. If set to true the text search will only match text where upper and lower case letters are identical to the ones specified in the Strings specified using setSearchStrings(String[]).

Examples:

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()

Parameters:
enable - set to true if search should be case sensitive.
Throws:
IllegalStateException - if the search request is not modifiable (see AbstractCharSequenceSearchRequest.isModifiable()

setSearchStrings

public void setSearchStrings(String[] searchStrings)
specifies the strings for which the text search should search for. The Strings 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()

Parameters:
searchStrings - an array of Strings to search for.
Throws:
IllegalArgumentException - if the searchStrings are null or an array with a size of zero
IllegalStateException - if the search request is not modifiable (see AbstractCharSequenceSearchRequest.isModifiable()

setWholeWordsOnly

public void setWholeWordsOnly(boolean enable)
Specifies wether it should be searched for whole words only or not. If set to true the text search will only match text where the string inside the page has a space character in front and behind it.

Examples: (spaces will be represented as underscore (_) characters)

Examples
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()

Parameters:
enable - set to true if the text search should search for whole words only.
Throws:
IllegalStateException - if the search request is not modifiable (see AbstractCharSequenceSearchRequest.isModifiable()

createMatcher

protected CharSequenceMatcher createMatcher()
Description copied from class: AbstractCharSequenceSearchRequest
Creates a CharSequenceMatcher. This method may never return null.

Specified by:
createMatcher in class AbstractCharSequenceSearchRequest
Returns:
a ready-to-use CharSequenceMatcher


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.