ice.pilots.html4
Class Search

java.lang.Object
  extended byice.pilots.html4.Search

public class Search
extends Object

Search support for HTML4 pilot. By default the search is case-insensitive. This object supports both modal and non-modal operation. Clients of this class should know that an instance of a Search object is linked to an instance of a Viewport, by intermediate classes, and that alterations in the Viewport hierarchy that reflect changes in focus or Viewport activation must be handled outside of this object.

Clients may use this object in a modal form, where a popup dialog allows the user to make selections to the search parameters, and then submitting the search at that point.

  1. Create a new Search object
  2. Allow users to set values on a dialog
  3. Call the property setters on this object to set all the values, and
  4. Call searchDocument to search the document
  5. Call findNext and findPrevious to select the next and previous matches in the document, respectively.
  6. Call Dispose on the Search when the dialog is dismissed.
Clients using this object as a Search object for a non-modal toolbar type of Search class (ala Firefox) can do the following steps
  1. Create a new Search object
  2. When a user changes a setting on the dialog, the setter can be called on the Search object. Immediately, the Client should call searchDocument to see the changes take place immediately. If the change does not invalidate the search, the Search object will not perform a new search.
  3. Call Dispose on the Search object when the dialog is dismissed.


Method Summary
 void dispose()
          Dispose of this search object.
 boolean findNext()
          Select the next instance of a search match.
 boolean findPrevious()
          Find previous occurance of the search string.
 boolean getMatchCase()
          Get current case-sensetivity.
 String getSearchText()
          Retrieve the current search string.
 boolean getWholeWordSearch()
          Gets the current whole-word search setting.
 boolean isHighlightSearches()
          Retrieve the highlightSearches property.
 int searchDocument()
          Expose a legacy form of the method that, by default, searches and selects the first occurance of the match.
 int searchDocument(boolean selectFirst)
          This method will check if (any) current setting changes to the properties of the search require a new search.
 void setHightlightSearches(boolean highlightSearch)
          Set the highlightSearches property.
 void setMatchCase(boolean flag)
          Set case-sensetivity.
 void setSearchPosToStart()
          Start next search from the beginning of the document
 void setSearchText(String str)
          Set the search string for a new search.
 void setWholeWordSearch(boolean flag)
          Sets whole-word search setting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

dispose

public void dispose()
Dispose of this search object. This method should be called after the searching is done.


setSearchPosToStart

public void setSearchPosToStart()
Start next search from the beginning of the document


setWholeWordSearch

public void setWholeWordSearch(boolean flag)
Sets whole-word search setting. When enabled, whole-word searching limits search results to text that matches the search String, and is also surrounded by a whitespace characters.

By default the whole-word searching is disabled.

Changing the setting of this property will invalidate the current search set.

Parameters:
flag - true to enabled whole-word searching, false otherwise.

getWholeWordSearch

public boolean getWholeWordSearch()
Gets the current whole-word search setting.

Returns:
true if whole-word search is enabled, false otherwise

setHightlightSearches

public void setHightlightSearches(boolean highlightSearch)
Set the highlightSearches property. If set to true, this Search object will highlight all matching search strings in the document. The individually selected search item is maintained seperately from this list of highlights, so the search selection will visually supercede the highlight coloring.

Setting/clearing the highlightSearch flag requires apply to be called to take effect, but does not in itself require a new search to be performed

Parameters:
highlightSearch - true if all matching searches are to be highlighted.
Since:
6.1

isHighlightSearches

public boolean isHighlightSearches()
Retrieve the highlightSearches property. If true, the Search object will highlight the search ranges of any search performed.

Returns:
true if highlightSearches property is enabled
Since:
6.1

setSearchText

public void setSearchText(String str)
Set the search string for a new search. The complete document must be re-searched if the search string has changed, and the existing highlight and search values must be discareded.

Parameters:
str - text to search for

getSearchText

public String getSearchText()
Retrieve the current search string. The return value is always the same as the value that was set, it has not been modified to match the case of the search.

Returns:
Since:
6.1

setMatchCase

public void setMatchCase(boolean flag)
Set case-sensetivity. By default the search is case-insensetive. This operation requires a re-search of the document, since this operation will require a

Parameters:
flag - true if search is case-sensetive, false otherwise.

getMatchCase

public boolean getMatchCase()
Get current case-sensetivity.

Returns:
true if search is case-sensetive, false otherwise

searchDocument

public int searchDocument()
Expose a legacy form of the method that, by default, searches and selects the first occurance of the match.

Returns:
the number of matches found in the document
Since:
6,1

searchDocument

public int searchDocument(boolean selectFirst)
This method will check if (any) current setting changes to the properties of the search require a new search. If so,
  1. A new search will be performed
  2. If the selectFirst argument is true, the first matching search result, if any, will be selected
Clients of the search object can make several setting changes, and then call this method to apply them all. Other clients with interactive toolbar approaches may change settings and then apply them after each change, resulting in a more immediate experience for the user.

Parameters:
selectFirst - True if this search is to select the first match, if any.
Returns:
returns the number of matches found in the document
Since:
6.1

findNext

public boolean findNext()
Select the next instance of a search match. For compatibility, this method will call apply() if the search has been measurably altered.

Returns:
true if the search vector contains more matches, false if all the matches have been selected.

findPrevious

public boolean findPrevious()
Find previous occurance of the search string. If searchDocument has not been called, this method will search the document and mark the last found match. If there is no previous match, this method will return false, and wrap the match entries, allowing continued calling of this method (implementing an internal wrap method).

Returns:
false if not found, true otherwise