Eclipse Platform
Release 3.2

org.eclipse.jface.text
Class FindReplaceDocumentAdapter

java.lang.Object
  extended by org.eclipse.jface.text.FindReplaceDocumentAdapter
All Implemented Interfaces:
java.lang.CharSequence

public class FindReplaceDocumentAdapter
extends java.lang.Object
implements java.lang.CharSequence

Provides search and replace operations on IDocument.

Replaces IDocument.search(int, String, boolean, boolean, boolean).

Since:
3.0

Constructor Summary
FindReplaceDocumentAdapter(IDocument document)
          Constructs a new find replace document adapter.
 
Method Summary
 char charAt(int index)
           
 IRegion find(int startOffset, java.lang.String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch)
          Returns the location of a given string in this adapter's document based on a set of search criteria.
 int length()
           
 IRegion replace(java.lang.String text, boolean regExReplace)
          Substitutes the previous match with the given text.
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FindReplaceDocumentAdapter

public FindReplaceDocumentAdapter(IDocument document)
Constructs a new find replace document adapter.

Parameters:
document - the adapted document
Method Detail

find

public IRegion find(int startOffset,
                    java.lang.String findString,
                    boolean forwardSearch,
                    boolean caseSensitive,
                    boolean wholeWord,
                    boolean regExSearch)
             throws BadLocationException
Returns the location of a given string in this adapter's document based on a set of search criteria.

Parameters:
startOffset - document offset at which search starts
findString - the string to find
forwardSearch - the search direction
caseSensitive - indicates whether lower and upper case should be distinguished
wholeWord - indicates whether the findString should be limited by white spaces as defined by Character.isWhiteSpace. Must not be used in combination with regExSearch.
regExSearch - if true findString represents a regular expression Must not be used in combination with wholeWord.
Returns:
the find or replace region or null if there was no match
Throws:
BadLocationException - if startOffset is an invalid document offset
java.util.regex.PatternSyntaxException - if a regular expression has invalid syntax

replace

public IRegion replace(java.lang.String text,
                       boolean regExReplace)
                throws BadLocationException
Substitutes the previous match with the given text. Sends a DocumentEvent to all registered IDocumentListener.

Parameters:
text - the substitution text
regExReplace - if true text represents a regular expression
Returns:
the replace region or null if there was no match
Throws:
BadLocationException - if startOffset is an invalid document offset
java.lang.IllegalStateException - if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation
java.util.regex.PatternSyntaxException - if a regular expression has invalid syntax
See Also:
DocumentEvent, IDocumentListener

length

public int length()
Specified by:
length in interface java.lang.CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.