Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.util.regex
Class Matcher

java.lang.Object
  extended by ch.randelshofer.util.regex.Matcher

public class Matcher
extends java.lang.Object

Searches for an occurence of a case sensitive text on a document.

Version:
1.0 2002-02-11
Author:
Werner Randelshofer

Constructor Summary
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, boolean matchWord)
          Creates a new instance of Matcher
 
Method Summary
 int find()
          Attempts to find the next subsequence of the input sequence that matches the pattern.
 int find(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.
 java.lang.String getFindString()
           
 void reset()
          Resets the startIndex of the matcher to 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 examined
findString - The string to be searched.

Matcher

public Matcher(javax.swing.text.Document document,
               java.lang.String findString,
               boolean matchCase,
               boolean matchWord)
Creates a new instance of Matcher

Parameters:
document - The document to be examined
findString - The string to be searched.
matchCase - Set to true for case sensitive search.
matchWord - Set to true for word match search.
Method Detail

getFindString

public java.lang.String getFindString()

find

public int find(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.

find

public int find()
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:
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.


Copyright 2012-02-25 Werner Randelshofer