Class JXEditorPane.DocumentSearchable
java.lang.Object
org.jdesktop.swingx.JXEditorPane.DocumentSearchable
- All Implemented Interfaces:
Searchable
- Enclosing class:
JXEditorPane
A
Searchable implementation for Documents.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) MatchResult(package private) String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanfoundExtendedMatch(Pattern pattern, int start) Search from same startIndex as the previous search.private MatchResultgetMatchResult(Matcher matcher, boolean useFirst) protected booleanchecks if the searchString should be interpreted as empty.private booleanmaybeExtendedMatch(int startIndex) Checks if the startIndex is a candidate for trying a re-match.intSearchsearchStringfrom the beginning of a document.intSearchsearchStringfrom the given position in a document.intSearchsearchStringin the given direction from the some position in a document.intSearch for the pattern from the beginning of the document.intSearch for the pattern from the start index.intSearch for the pattern from the start index.private intupdateStateAfterFound(MatchResult currentResult, int offset) private void
-
Field Details
-
lastFoundIndex
int lastFoundIndex -
lastMatchResult
MatchResult lastMatchResult -
lastRegEx
String lastRegEx
-
-
Constructor Details
-
DocumentSearchable
public DocumentSearchable()
-
-
Method Details
-
search
Description copied from interface:SearchableSearchsearchStringfrom the beginning of a document.- Specified by:
searchin interfaceSearchable- Parameters:
searchString-Stringwe should find in a document.- Returns:
- index of matched
Stringor -1 if a match cannot be found.
-
search
Description copied from interface:SearchableSearchsearchStringfrom the given position in a document.- Specified by:
searchin interfaceSearchable- Parameters:
searchString-Stringwe should find in a document.columnIndex- Start position in a document or -1 if we want to search from the beginning.- Returns:
- index of matched
Stringor -1 if a match cannot be found.
-
search
Description copied from interface:SearchableSearchsearchStringin the given direction from the some position in a document.- Specified by:
searchin interfaceSearchable- Parameters:
searchString-Stringwe should find in a document.columnIndex- Start position in a document or -1 if we want to search from the beginning.backward- Indicates search direction, will search from the given position towards the beginning of a document if this parameter istrue.- Returns:
- index of matched
Stringor -1 if a match cannot be found.
-
isEmpty
checks if the searchString should be interpreted as empty. here: returns true if string is null or has zero length. TODO: This should be in a utility class.- Parameters:
searchString-- Returns:
- true if string is null or has zero length
-
search
Description copied from interface:SearchableSearch for the pattern from the beginning of the document.- Specified by:
searchin interfaceSearchable- Parameters:
pattern- Pattern for search- Returns:
- index of matched
Patternor -1 if a match cannot be found.
-
search
Description copied from interface:SearchableSearch for the pattern from the start index.- Specified by:
searchin interfaceSearchable- Parameters:
pattern- Pattern for searchstartIndex- starting index of search. If -1 then start from the beginning- Returns:
- index of matched pattern or -1 if a match cannot be found.
-
search
Description copied from interface:SearchableSearch for the pattern from the start index.- Specified by:
searchin interfaceSearchable- Parameters:
pattern- Pattern for searchstartIndex- starting index of search. If -1 then start from the beginningbackwards- indicates the direction if true then search is backwards- Returns:
- start position of matching string or -1
-
foundExtendedMatch
Search from same startIndex as the previous search. Checks if the match is different from the last (either extended/reduced) at the same position. Returns true if the current match result represents a different match than the last, false if no match or the same.- Parameters:
pattern-start-- Returns:
- true if the current match result represents a different match than the last, false if no match or the same.
-
maybeExtendedMatch
private boolean maybeExtendedMatch(int startIndex) Checks if the startIndex is a candidate for trying a re-match.- Parameters:
startIndex-- Returns:
- true if the startIndex should be re-matched, false if not.
-
updateStateAfterFound
- Parameters:
currentResult-offset-- Returns:
- the start position of the selected text
-
getMatchResult
- Parameters:
matcher-useFirst- whether or not to return after the first match is found.- Returns:
MatchResultor null
-
updateStateAfterNotFound
private void updateStateAfterNotFound()
-