|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.icepdf.ri.common.search.DocumentSearchControllerImpl
public class DocumentSearchControllerImpl
Document search controller used to manage document searches. This class class takes care of many of the performance issues of doing searches on larges documents and is also used by PageViewComponentImpl to highlight search results.
This implementation uses simple search algorithm that will work well for most users. This class can be extended and the methodsearchHighlightPage(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.
| Field Summary | |
|---|---|
protected org.icepdf.core.pobjects.Document |
document
|
protected DocumentSearchModelImpl |
searchModel
|
protected SwingController |
viewerController
|
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DocumentSearchModelImpl searchModel
protected SwingController viewerController
protected org.icepdf.core.pobjects.Document document
| Constructor Detail |
|---|
public DocumentSearchControllerImpl(SwingController viewerController)
viewerController - parent controller/mediator.public DocumentSearchControllerImpl(org.icepdf.core.pobjects.Document document)
document - document to search.| Method Detail |
|---|
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 for
public 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 search
public 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 LineText
public java.util.ArrayList<org.icepdf.core.pobjects.graphics.text.WordText> searchPage(int pageIndex)
searchPage in interface org.icepdf.core.search.DocumentSearchControllerpageIndex - page to search
public 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.DocumentSearchController
public 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||