Package org.eclipse.jface.text
Class FindReplaceDocumentAdapter
java.lang.Object
org.eclipse.jface.text.FindReplaceDocumentAdapter
- All Implemented Interfaces:
CharSequence
Provides search and replace operations on
IDocument.
Replaces
IDocument.search(int, String, boolean, boolean, boolean).
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionFindReplaceDocumentAdapter(IDocument document) Constructs a new find replace document adapter. -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) static StringescapeForRegExPattern(String string) Escapes special characters in the string, such that the resulting pattern matches the given string.find(int startOffset, 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()Substitutes the previous match with the given text.subSequence(int start, int end) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
FindReplaceDocumentAdapter
Constructs a new find replace document adapter.- Parameters:
document- the adapted document
-
-
Method Details
-
find
public IRegion find(int startOffset, 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 offsetPatternSyntaxException- if a regular expression has invalid syntax
-
replace
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 offsetIllegalStateException- if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operationPatternSyntaxException- if a regular expression has invalid syntax- See Also:
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
escapeForRegExPattern
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
-