public class DocumentSearchControllerImpl
extends java.lang.Object
implements org.icepdf.core.search.DocumentSearchController
searchHighlightPage(int)
can be overridden for custom search implementations.
The DocumentSearchControllerImpl can be constructed to be used with the
Viewer RI source code via the constructor that takes a SwingController as
a parameter. The second variation is ended for a headless environment where
Swing is not needed, the constructor for this instance takes a Document
as a parameter.| Modifier and Type | Field and Description |
|---|---|
protected org.icepdf.core.pobjects.Document |
document |
protected DocumentSearchModelImpl |
searchModel |
protected SwingController |
viewerController |
| Constructor and Description |
|---|
DocumentSearchControllerImpl(org.icepdf.core.pobjects.Document document)
Create a news instance of search controller intended to be used in a
headless environment.
|
DocumentSearchControllerImpl(SwingController viewerController)
Create a news instance of search controller.
|
| Modifier and Type | Method and Description |
|---|---|
org.icepdf.core.search.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,
org.icepdf.core.pobjects.graphics.text.PageText pageText)
Test to see if a search highlight is needed.
|
void |
removeSearchTerm(org.icepdf.core.search.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.ArrayList<org.icepdf.core.pobjects.graphics.text.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<org.icepdf.core.pobjects.graphics.text.WordText> |
searchPage(int pageIndex)
Search page but only return words that are hits.
|
protected java.util.ArrayList<java.lang.String> |
searchPhraseParser(java.lang.String phrase)
Utility for breaking the pattern up into searchable words.
|
protected DocumentSearchModelImpl searchModel
protected SwingController viewerController
protected org.icepdf.core.pobjects.Document document
public DocumentSearchControllerImpl(SwingController viewerController)
viewerController - parent controller/mediator.public DocumentSearchControllerImpl(org.icepdf.core.pobjects.Document document)
document - document to search.public int searchHighlightPage(int pageIndex,
java.lang.String term,
boolean caseSensitive,
boolean wholeWord)
addSearchTerm(String, boolean, boolean) and the
method searchPage(int) should be called after each term is
added or after all have been added.searchHighlightPage in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page to searchcaseSensitive - if true use case sensitive searcheswholeWord - if true use whole word searchesterm - term to search forpublic int searchHighlightPage(int pageIndex)
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.searchHighlightPage in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page index to searchpublic java.util.ArrayList<org.icepdf.core.pobjects.graphics.text.LineText> searchHighlightPage(int pageIndex,
int wordPadding)
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.searchHighlightPage in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page index to searchwordPadding - word padding on either side of hit to give context
to found woords in the returned LineTextpublic java.util.ArrayList<org.icepdf.core.pobjects.graphics.text.WordText> searchPage(int pageIndex)
searchPage in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page to searchpublic org.icepdf.core.search.SearchTerm addSearchTerm(java.lang.String term,
boolean caseSensitive,
boolean wholeWord)
addSearchTerm in interface org.icepdf.core.search.DocumentSearchControllerterm - single word or phrace to search for.caseSensitive - is search case sensitive.wholeWord - is search whole word senstive.public void removeSearchTerm(org.icepdf.core.search.SearchTerm searchTerm)
removeSearchTerm in interface org.icepdf.core.search.DocumentSearchControllersearchTerm - search term to remove.public void clearSearchHighlight(int pageIndex)
clearSearchHighlight in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page indext to clearpublic void clearAllSearchHighlight()
clearAllSearchHighlight in interface org.icepdf.core.search.DocumentSearchControllerpublic boolean isSearchHighlightRefreshNeeded(int pageIndex,
org.icepdf.core.pobjects.graphics.text.PageText pageText)
isSearchHighlightRefreshNeeded in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page index to text for restuls.pageText - current pageText object associated with the pageIndex.public void dispose()
dispose in interface org.icepdf.core.search.DocumentSearchControllerprotected java.util.ArrayList<java.lang.String> searchPhraseParser(java.lang.String phrase)
phrase - pattern to search words for.