com.levigo.jadice.search
Class PatternSearchRequest
java.lang.Object
com.levigo.jadice.search.AbstractCharSequenceSearchRequest
com.levigo.jadice.search.PatternSearchRequest
public class PatternSearchRequest
- extends AbstractCharSequenceSearchRequest
A variation of a AbstractCharSequenceSearchRequest
which allows
searching using Pattern
s. This kind of
search request
is mainly useful for
batch processing of documents. A array of patterns has to be set using the
setPatterns(Pattern[])
method. Each one will be executed, in the
indexing order of the array.
The PatternSearchRequest
will provide the matching pattern as the
handback value of Result
. Please see Result.getHandback()
and
MatchConsumer.match(int, int, Object)
for details.
- Author:
- Francois Fernandes
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 |
PatternSearchRequest
public PatternSearchRequest()
setPatterns
public void setPatterns(Pattern[] patterns)
- Assign an array of Patterns to this
PatternSearchRequest
. The array must not be null,
have a zero length and no element in the array may be null
. Is one of the
conditions, mentioned before, violated this method will throw an
IllegalArgumentException
.
- Parameters:
patterns
- the Pattern
s to search for.
- Throws:
IllegalArgumentException
- if the array is null or has zero length.
getPatterns
public Pattern[] getPatterns()
- Returns the
Pattern
s applied to this PatternSearchRequest
or null
if no patterns have been applied yet.
- Returns:
- the
Pattern
s applied to this PatternSearchRequest
or null
if no patterns have been applied yet.
isValid
public boolean isValid()
- Extends the
AbstractCharSequenceSearchRequest.isValid()
by
requiring a valid array of Pattern
s. Please see
AbstractCharSequenceSearchRequest.isValid()
for details.
- Overrides:
isValid
in class AbstractCharSequenceSearchRequest
- Returns:
true
if the configuration is sufficient- See Also:
AbstractCharSequenceSearchRequest.isValid()
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