-
- All Implemented Interfaces:
-
org.readium.r2.shared.publication.Publication.Service,org.readium.r2.shared.publication.services.search.SearchService,org.readium.r2.shared.util.Closeable
public final class StringSearchService implements SearchService
Base implementation of SearchService iterating through the content of Publication's resources.
To stay media-type-agnostic, StringSearchService relies on ResourceContentExtractor implementations to retrieve the pure text content from markups (e.g. HTML) or binary (e.g. PDF) resources.
The actual search is implemented by the provided searchAlgorithm.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classStringSearchService.Companionpublic interfaceStringSearchService.AlgorithmImplements the actual search algorithm in sanitized text content.
public final classStringSearchService.IcuAlgorithmImplementation of a search Algorithm using ICU components to perform the actual search while taking into account languages specificities.
public final classStringSearchService.NaiveAlgorithmA naive search Algorithm performing exact matches on strings.
There are no safe ways to perform case insensitive search using String.indexOf with all languages, so this Algorithm does not have any options. Use IcuAlgorithm for better results.
-
Constructor Summary
Constructors Constructor Description StringSearchService(Ref<Publication> publication, String language, Integer snippetLength, StringSearchService.Algorithm searchAlgorithm, ResourceContentExtractor.Factory extractorFactory)
-
Method Summary
Modifier and Type Method Description SearchService.OptionsgetOptions()Default value for the search options of this service. final StringgetLanguage()Try<SearchIterator, SearchException>search(String query, SearchService.Options options)Starts a new search through the publication content, with the given query. -
-
Constructor Detail
-
StringSearchService
StringSearchService(Ref<Publication> publication, String language, Integer snippetLength, StringSearchService.Algorithm searchAlgorithm, ResourceContentExtractor.Factory extractorFactory)
-
-
Method Detail
-
getOptions
SearchService.Options getOptions()
Default value for the search options of this service.
If an option does not have a value, it is not supported by the service.
-
getLanguage
final String getLanguage()
-
search
Try<SearchIterator, SearchException> search(String query, SearchService.Options options)
Starts a new search through the publication content, with the given query.
If an option is nil when calling search(), its value is assumed to be the default one.
-
-
-
-