com.levigo.jadice.search
Class AbstractCharSequenceSearchRequest

java.lang.Object
  extended by com.levigo.jadice.search.AbstractCharSequenceSearchRequest
Direct Known Subclasses:
PatternSearchRequest, SearchRequest

public abstract class AbstractCharSequenceSearchRequest
extends Object


Field Summary
static String PROPERTY_PAGES
          page list property.
 
Constructor Summary
protected AbstractCharSequenceSearchRequest()
           
 
Method Summary
 void addSearchStateListener(SearchStateListener listener)
          Add a SearchStateListener to the AbstractCharSequenceSearchRequest to get SearchStateChangeEvents if the state of the request changed.
 void cancel()
          cancel the current request
protected abstract  CharSequenceMatcher createMatcher()
          Creates a CharSequenceMatcher.
protected  void ensureModifiable()
          Utility method which will throw a IllegalStateException if isModifiable() returns false
protected  void ensureNotRunning()
           
protected  void ensureValid()
           
 void execute()
           
 void executeSync()
          Executes this AbstractCharSequenceSearchRequest (or implementation) synchronous on the current thread.
<T> T
getInternalHook(Class<T> clazz)
          THIS IS A JADICE INTERNAL METHOD. Use is only for internal purposes.
 List<Page> getPages()
          the Pages that have been specified using the setPages(List) method.
 EventList<Result> getResultList()
           
 SearchRequest.SearchState getState()
           
 boolean isModifiable()
          Informs if the AbstractCharSequenceSearchRequest is modifiable or not.
 boolean isRunning()
          checks if the AbstractCharSequenceSearchRequest is currently being processed by the internal search engine.
 boolean isValid()
          Checks if the configuration of the AbstractCharSequenceSearchRequest is sufficient.
 void reset()
          Reset the current request.
 void setPages(List<Page> pages)
          Specifies the Pages to search in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_PAGES

public static final String PROPERTY_PAGES
page list property.

See Also:
setPages(List), Constant Field Values
Constructor Detail

AbstractCharSequenceSearchRequest

protected AbstractCharSequenceSearchRequest()
Method Detail

addSearchStateListener

public final void addSearchStateListener(SearchStateListener listener)
Add a SearchStateListener to the AbstractCharSequenceSearchRequest to get SearchStateChangeEvents if the state of the request changed.

Parameters:
listener - the SearchStateListener to be added

cancel

public void cancel()
cancel the current request

Throws:
IllegalStateException - if the AbstractCharSequenceSearchRequest is not running

reset

public void reset()
Reset the current request.

Throws:
IllegalStateException - if the AbstractCharSequenceSearchRequest is not running

ensureModifiable

protected void ensureModifiable()
Utility method which will throw a IllegalStateException if isModifiable() returns false


execute

public void execute()
Throws:
IllegalStateException - if the search request is not properly initialized

ensureNotRunning

protected void ensureNotRunning()

ensureValid

protected void ensureValid()

executeSync

public void executeSync()
Executes this AbstractCharSequenceSearchRequest (or implementation) synchronous on the current thread. It will not have any influence on other searches running parallel.

Throws:
IllegalStateException - if the search request is not properly initialized
Since:
4.3

getInternalHook

public <T> T getInternalHook(Class<T> clazz)
THIS IS A JADICE INTERNAL METHOD. Use is only for internal purposes.


getPages

public List<Page> getPages()
the Pages that have been specified using the setPages(List) method.

Returns:
the Pages that have been specified using setPages(List)
See Also:
setPages(List)

isModifiable

public boolean isModifiable()
Informs if the AbstractCharSequenceSearchRequest is modifiable or not. A AbstractCharSequenceSearchRequest is modifiable as long it hasn't been executed using the execute() method. If the request has been executed any changes using methods like setPages(List) will result in a IllegalStateException. Once the internal search enginge completes its work or has been cancelled using the cancel() method, the AbstractCharSequenceSearchRequest will become modifiable again.
As the text searching works asynchronous in the background the AbstractCharSequenceSearchRequest will not be modifiable directly after a call to the cancel() method. The internal search engine will stop searching at a unspecified moment after the cancel() has been invoked.

Returns:
whether the request is modifiable.

isRunning

public boolean isRunning()
checks if the AbstractCharSequenceSearchRequest is currently being processed by the internal search engine.

Returns:
true if this SearchRequest is currently being processed

isValid

public boolean isValid()
Checks if the configuration of the AbstractCharSequenceSearchRequest is sufficient. Whether or not a AbstractCharSequenceSearchRequest is valid is up to the specific implementation. AbstractCharSequenceSearchRequest will check if pages have been supplied.

Returns:
true if the configuration is sufficient

setPages

public void setPages(List<Page> pages)
Specifies the Pages to search in. This method will create a copy of the shapshot of the list of pages, so that later modifications to the list of pages have no effect.

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 AbstractCharSequenceSearchRequest, please see isModifiable()

Parameters:
pages - the pages to search for text in
Throws:
IllegalArgumentException - if pages is null of has a size of zero
IllegalStateException - if the search request is not modifiable (see isModifiable()

createMatcher

protected abstract CharSequenceMatcher createMatcher()
Creates a CharSequenceMatcher. This method may never return null.

Returns:
a ready-to-use CharSequenceMatcher
Since:
4.3

getResultList

public EventList<Result> getResultList()
Returns:
the resultList

getState

public SearchRequest.SearchState getState()
Returns:
the state


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