Package org.eclipse.jface.text
Class FindReplaceDocumentAdapter
- java.lang.Object
-
- org.eclipse.jface.text.FindReplaceDocumentAdapter
-
- All Implemented Interfaces:
java.lang.CharSequence
public class FindReplaceDocumentAdapter extends java.lang.Object implements java.lang.CharSequenceProvides search and replace operations onIDocument.Replaces
IDocument.search(int, String, boolean, boolean, boolean).- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description FindReplaceDocumentAdapter(IDocument document)Constructs a new find replace document adapter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)static java.lang.StringescapeForRegExPattern(java.lang.String string)Escapes special characters in the string, such that the resulting pattern matches the given string.IRegionfind(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.intlength()IRegionreplace(java.lang.String text, boolean regExReplace)Substitutes the previous match with the given text.java.lang.CharSequencesubSequence(int start, int end)java.lang.StringtoString()
-
-
-
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 startsfindString- the string to findforwardSearch- the search directioncaseSensitive- indicates whether lower and upper case should be distinguishedwholeWord- indicates whether the findString should be limited by white spaces as defined by Character.isWhiteSpace. Must not be used in combination withregExSearch.regExSearch- iftruefindString represents a regular expression Must not be used in combination withwholeWord.- Returns:
- the find or replace region or
nullif there was no match - Throws:
BadLocationException- if startOffset is an invalid document offsetjava.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 aDocumentEventto all registeredIDocumentListener.- Parameters:
text- the substitution textregExReplace- iftruetextrepresents a regular expression- Returns:
- the replace region or
nullif there was no match - Throws:
BadLocationException- if startOffset is an invalid document offsetjava.lang.IllegalStateException- if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operationjava.util.regex.PatternSyntaxException- if a regular expression has invalid syntax- See Also:
DocumentEvent,IDocumentListener
-
length
public int length()
- Specified by:
lengthin interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)- Specified by:
subSequencein interfacejava.lang.CharSequence
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object
-
escapeForRegExPattern
public static java.lang.String escapeForRegExPattern(java.lang.String string)
Escapes special characters in the string, such that the resulting pattern matches the given string.- Parameters:
string- the string to escape- Returns:
- a regex pattern that matches the given string
- Since:
- 3.5
-
-