com.cometway.text
Class TextFinder

java.lang.Object
  extended by com.cometway.text.TextFinder
All Implemented Interfaces:
ITextFinder

public class TextFinder
extends java.lang.Object
implements ITextFinder

A text finder which uses generic search algorithms.


Constructor Summary
TextFinder()
          Initializes a text finder with a null search string, case sensitivity turned on, and search backwards turned off.
TextFinder(java.lang.String searchString)
          Initializes a text finder with the specified search string, case sensitivity turned on, and search backwards turned off.
TextFinder(java.lang.String searchString, boolean caseInsensitive)
          Initializes a text finder with the specified search string and case sensitivity, and search backwards turned off.
 
Method Summary
 TextFinderResult findText(char[] buffer, int bufferLength, int fromIndex)
          Returns the first matching text range beginning at the specified location using the specified search parameters.
 TextFinderResult findTextBackwards(char[] buffer, int bufferLength, int fromIndex)
           
 TextFinderResult findTextForwards(char[] buffer, int bufferLength, int fromIndex)
           
 boolean getCaseInsensitive()
          Returns true if the text finder will ignore case; false otherwise.
 boolean getSearchBackwards()
          Returns true if the text finder will search backwards; false otherwise.
 java.lang.String getSearchString()
          Returns the current search string.
 void setCaseInsensitive(boolean state)
          When set to true, the text finder will ignore case.
 void setSearchBackwards(boolean state)
          When set to true, the text finder will search backwards.
 void setSearchString(java.lang.String str)
          Sets the search string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFinder

public TextFinder()
Initializes a text finder with a null search string, case sensitivity turned on, and search backwards turned off.


TextFinder

public TextFinder(java.lang.String searchString)
Initializes a text finder with the specified search string, case sensitivity turned on, and search backwards turned off.


TextFinder

public TextFinder(java.lang.String searchString,
                  boolean caseInsensitive)
Initializes a text finder with the specified search string and case sensitivity, and search backwards turned off.

Method Detail

getCaseInsensitive

public boolean getCaseInsensitive()
Returns true if the text finder will ignore case; false otherwise.


getSearchBackwards

public boolean getSearchBackwards()
Returns true if the text finder will search backwards; false otherwise.


getSearchString

public java.lang.String getSearchString()
Returns the current search string.


findText

public TextFinderResult findText(char[] buffer,
                                 int bufferLength,
                                 int fromIndex)
Returns the first matching text range beginning at the specified location using the specified search parameters.

Specified by:
findText in interface ITextFinder
Parameters:
buffer - a character array where the text to be searched is located.
bufferLength - the number of valid characters in the character array.
fromIndex - the index from where the search should begin.
Returns:
an TextFinderResult representing the matching range of text.

findTextBackwards

public TextFinderResult findTextBackwards(char[] buffer,
                                          int bufferLength,
                                          int fromIndex)

findTextForwards

public TextFinderResult findTextForwards(char[] buffer,
                                         int bufferLength,
                                         int fromIndex)

setCaseInsensitive

public void setCaseInsensitive(boolean state)
When set to true, the text finder will ignore case.


setSearchBackwards

public void setSearchBackwards(boolean state)
When set to true, the text finder will search backwards.


setSearchString

public void setSearchString(java.lang.String str)
Sets the search string.