org.jhotdraw.samples.teddy.regex
Class Matcher
- java.lang.Object
-
- org.jhotdraw.samples.teddy.regex.Matcher
-
public class Matcher extends java.lang.ObjectSearches for an occurence of a case (in)sensitive text on a document. This is a rather slow implementation that does not use advanced techniques such as Boyer-Moore.
-
-
Constructor Summary
Constructors Constructor and Description Matcher(javax.swing.text.Document document, java.lang.String findString)Creates a new instance of Matcher which performs a case sensitive search.Matcher(javax.swing.text.Document document, java.lang.String findString, boolean matchCase, MatchType matchType)Creates a new instance of Matcher
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intfindNext()Attempts to find the next subsequence of the input sequence that matches the pattern.intfindNext(int startIndex)Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.intfindPrevious()Attempts to find the previous subsequence of the input sequence that matches the pattern.intfindPrevious(int startIndex)Resets this matcher and then attempts to find the previous subsequence of the input sequence that matches the pattern, starting at the specified index.java.lang.StringgetFindString()MatchTypegetMatchType()booleanisMatchCase()voidreset()Resets the startIndex of the matcher to 0.voidsetStartIndex(int newValue)Sets the start index for the findNext(), findPrevious() methods.
-
-
-
Constructor Detail
-
Matcher
public Matcher(javax.swing.text.Document document, java.lang.String findString)Creates a new instance of Matcher which performs a case sensitive search.- Parameters:
document- The document to be examinedfindString- The string to be searched.
-
Matcher
public Matcher(javax.swing.text.Document document, java.lang.String findString, boolean matchCase, MatchType matchType)Creates a new instance of Matcher- Parameters:
document- The document to be examinedfindString- The string to be searched.matchCase- Set to true for case sensitive search.matchType- Sets the match type.
-
-
Method Detail
-
getFindString
public java.lang.String getFindString()
-
isMatchCase
public boolean isMatchCase()
-
getMatchType
public MatchType getMatchType()
-
setStartIndex
public void setStartIndex(int newValue)
Sets the start index for the findNext(), findPrevious() methods.
-
findNext
public int findNext(int startIndex)
Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.- Parameters:
startIndex- the index from which to start the search.- Returns:
- the index of the first occurrence of the search string, starting at the specified offset, or -1 if no occurrence was found.
-
findNext
public int findNext()
Attempts to find the next subsequence of the input sequence that matches the pattern.This method starts at the beginning of the input sequence or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character not matched by the previous match.
- Returns:
- the index of the first occurrence of the search string, starting at the specified offset, or -1 if no occurrence was found.
-
findPrevious
public int findPrevious(int startIndex)
Resets this matcher and then attempts to find the previous subsequence of the input sequence that matches the pattern, starting at the specified index.- Parameters:
startIndex- the index from which to start the search.- Returns:
- the index of the first occurrence of the search string, starting at the specified offset, or -1 if no occurrence was found.
-
findPrevious
public int findPrevious()
Attempts to find the previous subsequence of the input sequence that matches the pattern.This method starts at the beginning of the input sequence or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character not matched by the previous match.
- Returns:
- the index of the first occurrence of the search string, starting at the specified offset, or -1 if no occurrence was found.
-
reset
public void reset()
Resets the startIndex of the matcher to 0.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG