org.icepdf.core.search
Interface DocumentSearchController


public interface DocumentSearchController

Document search controller interface for content text searches

Since:
4.0

Method Summary
 SearchTerm addSearchTerm(java.lang.String term, boolean caseSensitive, boolean wholeWord)
          Add the search term to the list of search terms.
 void clearAllSearchHighlight()
          Clears all highlighted text states for this this document.
 void clearSearchHighlight(int pageIndex)
          Clear all searched items for specified page.
 void dispose()
          Disposes controller clearing resources.
 boolean isSearchHighlightRefreshNeeded(int pageIndex, PageText pageText)
          Test to see if a search highlight is needed.
 void removeSearchTerm(SearchTerm searchTerm)
          Removes the specified search term from the search.
 int searchHighlightPage(int pageIndex)
          Searches the page index given the search terms that have been added with addSearchTerm(String, boolean, boolean).
 java.util.List<LineText> searchHighlightPage(int pageIndex, int wordPadding)
          Searches the page index given the search terms that have been added with addSearchTerm(String, boolean, boolean).
 int searchHighlightPage(int pageIndex, java.lang.String term, boolean caseSensitive, boolean wholeWord)
          Searches the given page using the specified term and properties.
 java.util.ArrayList<WordText> searchPage(int pageIndex)
          Search page but only return words that are hits.
 

Method Detail

searchHighlightPage

int searchHighlightPage(int pageIndex,
                        java.lang.String term,
                        boolean caseSensitive,
                        boolean wholeWord)
Searches the given page using the specified term and properties. The search model is updated to store the pages Page text as a weak reference which can be queried using isSearchHighlightNeeded to effiecently make sure that a pages text is highlighted even after a despose/init cycle. If the text state is no longer preseent then the search should be executed again.

This method cleasr the serach results for the page before it searches. If you wich to have cumligive search results then searches terms should be added with addSearchTerm(String, boolean, boolean) and the method searchPage(int) should be called after each term is added or after all have been added.

Parameters:
pageIndex - page to search
caseSensitive - if true use case sensitive searches
wholeWord - if true use whole word searches
term - term to search for
Returns:
number for hits for this page.

searchHighlightPage

int searchHighlightPage(int pageIndex)
Searches the page index given the search terms that have been added with addSearchTerm(String, boolean, boolean). If search hits where detected then the Page's PageText is added to the cache.

This method represent the core search algorithm for this DocumentSearchController implmentation. This method can be overriden if a different search algorithm or functinality is needed.

Parameters:
pageIndex - page index to search
Returns:
number of hits found for this page.

searchHighlightPage

java.util.List<LineText> searchHighlightPage(int pageIndex,
                                             int wordPadding)
Searches the page index given the search terms that have been added with addSearchTerm(String, boolean, boolean). If search hits where detected then the Page's PageText is added to the cache.

This class differences from searchHighlightPage(int) in that is returns a list of lineText fragements for each hit but the LinText is padded by pre and post words that surround the hit in the page context.

This method represent the core search algorithm for this DocumentSearchController implmentation. This method can be overriden if a different search algorithm or functinality is needed.

Parameters:
pageIndex - page index to search
wordPadding - word padding on either side of hit to give context to found words in the returned LineText. Values should be greater than zero
Returns:
number of hits found for this page.

searchPage

java.util.ArrayList<WordText> searchPage(int pageIndex)
Search page but only return words that are hits. Highlighting is till applied but this method can be used if other data needs to be extracted from the found words.

Parameters:
pageIndex - page to search
Returns:
list of words that match the term and search properites.

addSearchTerm

SearchTerm addSearchTerm(java.lang.String term,
                         boolean caseSensitive,
                         boolean wholeWord)
Add the search term to the list of search terms. The term is split into words based on white space and punctuation. No checks are done for duplication.

A new search needs to be executed for this change to take place.

Parameters:
term - single word or phrace to search for.
caseSensitive - is search case sensitive.
wholeWord - is search whole word senstive.
Returns:
searchTerm newly create search term.

removeSearchTerm

void removeSearchTerm(SearchTerm searchTerm)
Removes the specified search term from the search. A new search needs to be executed for this change to take place.

Parameters:
searchTerm - search term to remove.

clearSearchHighlight

void clearSearchHighlight(int pageIndex)
Clear all searched items for specified page.

Parameters:
pageIndex - page indext to clear

clearAllSearchHighlight

void clearAllSearchHighlight()
Clears all highlighted text states for this this document. This optimized to use the the SearchHighlightModel to only clear pages that still have selected states.


isSearchHighlightRefreshNeeded

boolean isSearchHighlightRefreshNeeded(int pageIndex,
                                       PageText pageText)
Test to see if a search highlight is needed. This is done by first check if there is a hit for this page and if the PageText object is the same as the one specified as a param. If they are not the same PageText object then we need to do refresh as the page was disposed and reinitialized with new content.

Parameters:
pageIndex - page index to text for restuls.
pageText - current pageText object associated with the pageIndex.
Returns:
true if refresh is needed, false otherwise.

dispose

void dispose()
Disposes controller clearing resources.