|
swingx Version 2005-08-19 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdesktop.swingx.AbstractSearchable
public abstract class AbstractSearchable
An abstract implementation of Searchable supporting incremental search. Keeps internal state to represent the previous search result. For all methods taking a string as parameter: compiles the String to a Pattern as-is and routes to the central method taking a Pattern.
| Nested Class Summary | |
|---|---|
static class |
AbstractSearchable.SearchResult
A convenience class to hold search state. |
| Field Summary | |
|---|---|
protected AbstractSearchable.SearchResult |
lastSearchResult
stores the result of the previous search. |
static String |
MATCH_HIGHLIGHTER
key for client property to use SearchHighlighter as match marker. |
static AbstractSearchable.SearchResult |
NO_MATCH
a constant representing not-found state. |
| Constructor Summary | |
|---|---|
AbstractSearchable()
|
|
| Method Summary | |
|---|---|
protected int |
adjustStartPosition(int startIndex,
boolean backwards)
Called if startIndex is different from last search
and make sure a backwards/forwards search starts at last/first row,
respectively. |
protected AbstractSearchable.SearchResult |
createSearchResult(Matcher matcher,
int row,
int column)
Factory method to create a SearchResult from the given parameters. |
protected int |
doSearch(Pattern pattern,
int startIndex,
boolean backwards)
Performs a search starting at the given startIndex using the pattern; Pattern. |
protected abstract AbstractSearchable.SearchResult |
findExtendedMatch(Pattern pattern,
int row)
called if sameRowIndex && ! |
protected abstract void |
findMatchAndUpdateState(Pattern pattern,
int startRow,
boolean backwards)
Loops through the searchable until a match is found or the end is reached. |
protected abstract int |
getSize()
returns the size of this searchable. |
protected boolean |
isEmpty(String searchString)
checks if the searchString should be interpreted as empty. |
protected boolean |
isEqualPattern(Pattern pattern)
Checks if the given Pattern should be considered as the same as in a previous search. |
protected boolean |
isEqualStartIndex(int startIndex)
Checks if the startIndex should be considered as the same as in the previous search. |
protected boolean |
isTrivialNoMatch(Pattern pattern,
int startIndex)
Checks and returns if it can be trivially decided to not match. |
protected boolean |
isValidIndex(int index)
checks if index is in range: 0 <= index < getSize(). |
protected abstract void |
moveMatchMarker()
Moves the match marker according to current found state. |
protected int |
moveStartPosition(int startIndex,
boolean backwards)
Moves the internal start position for matching as appropriate and returns the new startIndex to use. |
int |
search(Pattern pattern)
Performs a forward search starting at the beginning across the Searchable using the pattern; Pattern. |
int |
search(Pattern pattern,
int startIndex)
Performs a forward search starting at the given startIndex using the Pattern; Pattern. |
int |
search(Pattern pattern,
int startIndex,
boolean backwards)
Performs a search starting at the given startIndex using the pattern; Pattern. |
int |
search(String searchString)
Performs a forward search starting at the beginning across the Searchable using String that represents a regex pattern; Pattern. |
int |
search(String searchString,
int startIndex)
Performs a forward search starting at the given startIndex using String that represents a regex pattern; Pattern. |
int |
search(String searchString,
int startIndex,
boolean backward)
Performs a search starting at the given startIndex using String that represents a regex pattern; Pattern. |
protected void |
updateState(AbstractSearchable.SearchResult searchResult)
Update inner searchable state based on provided search result |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final AbstractSearchable.SearchResult NO_MATCH
protected AbstractSearchable.SearchResult lastSearchResult
public static final String MATCH_HIGHLIGHTER
| Constructor Detail |
|---|
public AbstractSearchable()
| Method Detail |
|---|
public int search(String searchString)
Pattern.
search in interface SearchablesearchString - String that we will try to locate
public int search(String searchString,
int startIndex)
Pattern.
search in interface SearchablesearchString - String that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginning
public int search(String searchString,
int startIndex,
boolean backward)
Pattern. The search direction
depends on the boolean parameter: forward/backward if false/true, respectively.
search in interface SearchablesearchString - String that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackward - true if we should perform search towards the beginning
public int search(Pattern pattern)
Pattern.
search in interface Searchablepattern - Pattern that we will try to locate
public int search(Pattern pattern,
int startIndex)
Pattern.
search in interface Searchablepattern - Pattern that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginning
public int search(Pattern pattern,
int startIndex,
boolean backwards)
Pattern.
The search direction depends on the boolean parameter:
forward/backward if false/true, respectively.
Updates visible and internal search state.
search in interface Searchablepattern - Pattern that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackwards - true if we should perform search towards the beginning
protected int doSearch(Pattern pattern,
int startIndex,
boolean backwards)
Pattern.
The search direction depends on the boolean parameter:
forward/backward if false/true, respectively.
Updates internal search state.
pattern - Pattern that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackwards - true if we should perform search towards the beginning
protected abstract void findMatchAndUpdateState(Pattern pattern,
int startRow,
boolean backwards)
pattern - Pattern that we will try to locatestartRow - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackwards - true if we should perform search towards the beginning
protected boolean isTrivialNoMatch(Pattern pattern,
int startIndex)
pattern - Pattern that we will try to locatestartIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginning
protected int adjustStartPosition(int startIndex,
boolean backwards)
startIndex is different from last search
and make sure a backwards/forwards search starts at last/first row,
respectively.
startIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackwards - true if we should perform search from towards the beginning
startIndex
protected int moveStartPosition(int startIndex,
boolean backwards)
startIndex - position in the document in the appropriate coordinates
from which we will start search or -1 to start from the beginningbackwards - true if we should perform search towards the beginning
startIndexprotected boolean isEqualPattern(Pattern pattern)
pattern - Pattern that we will compare with last request
Pattern is the same as the stored from
the previous search attemptprotected boolean isEqualStartIndex(int startIndex)
startIndex - startIndex that we will compare with the index
stored by the previous search request
protected boolean isEmpty(String searchString)
searchString - String that we should evaluate
String should be interpreted as empty
protected abstract AbstractSearchable.SearchResult findExtendedMatch(Pattern pattern,
int row)
pattern - Pattern that we will try to matchrow - position at which we will get the value to match with the provided Pattern
AbstractSearchable.SearchResult
protected AbstractSearchable.SearchResult createSearchResult(Matcher matcher,
int row,
int column)
matcher - the matcher after a successful find. Must not be null.row - the found indexcolumn - the found column
SearchResultprotected boolean isValidIndex(int index)
index - possible start position that we will check for validity
true if given parameter is valid indexprotected abstract int getSize()
protected void updateState(AbstractSearchable.SearchResult searchResult)
searchResult - SearchResult that represents the new state
of this AbstractSearchableprotected abstract void moveMatchMarker()
|
swingx Version 2005-08-19 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||