Package org.fife.ui.rtextarea
Class SearchResult
- java.lang.Object
-
- org.fife.ui.rtextarea.SearchResult
-
- All Implemented Interfaces:
Comparable<SearchResult>
public class SearchResult extends Object implements Comparable<SearchResult>
The result of a find, replace, or "mark all" operation.- See Also:
SearchEngine
-
-
Constructor Summary
Constructors Constructor Description SearchResult()
Constructor; indicates no match is found.SearchResult(DocumentRange range, int count, int markedCount)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(SearchResult other)
Compares this search result to another.boolean
equals(Object other)
Returns whether this search result represents the same logical result as another.int
getCount()
Returns the number of matches found or replaced.int
getMarkedCount()
Returns the number of instances marked.DocumentRange
getMatchRange()
If a find or replace operation is successful, this will be the range of text representing the found text (for "find" operations) or the replacement text inserted (for "replace" operations; for "replace all" operations this will be the last replacement region).int
hashCode()
Overridden simply as a best practice, sinceequals(Object)
is overridden.void
setCount(int count)
Sets the number of matches found or replaced.void
setMarkedCount(int markedCount)
Sets the number of marked occurrences found.void
setMatchRange(DocumentRange range)
Sets the selected range for this search operation.String
toString()
Returns a string representation of this object.boolean
wasFound()
Returns whether anything was found in this search operation.
-
-
-
Constructor Detail
-
SearchResult
public SearchResult()
Constructor; indicates no match is found.
-
SearchResult
public SearchResult(DocumentRange range, int count, int markedCount)
Constructor.- Parameters:
range
- The selected range of text after the find or replace operation. This can benull
if the selection was not changed.count
- The number of matches found or replaced. For regular "find" and "replace" operations, this will be zero or1
; for "replace all" operations, this will be the number of replacements.markedCount
- The number of matches marked. If "mark all" is disabled, this should be zero.
-
-
Method Detail
-
compareTo
public int compareTo(SearchResult other)
Compares this search result to another.- Specified by:
compareTo
in interfaceComparable<SearchResult>
- Parameters:
other
- Another search result to compare to.- Returns:
- How this result object should be sorted compared to
other
.
-
equals
public boolean equals(Object other)
Returns whether this search result represents the same logical result as another.
-
getCount
public int getCount()
Returns the number of matches found or replaced. For regular "find" and "replace" operations, this will be zero or1
. For "replace all" operations, this will be the number of replacements. For "mark all" operations, this will be zero.- Returns:
- The count.
- See Also:
setCount(int)
-
getMarkedCount
public int getMarkedCount()
Returns the number of instances marked. If "mark all" was not enabled, this will be0
.- Returns:
- The number of instances marked.
- See Also:
setMarkedCount(int)
-
getMatchRange
public DocumentRange getMatchRange()
If a find or replace operation is successful, this will be the range of text representing the found text (for "find" operations) or the replacement text inserted (for "replace" operations; for "replace all" operations this will be the last replacement region). If no match was found, or this was a "mark all" operation, this will benull
, since they do not update the editor's selection.- Returns:
- The matched range of text.
- See Also:
setMatchRange(DocumentRange)
-
hashCode
public int hashCode()
Overridden simply as a best practice, sinceequals(Object)
is overridden.
-
setCount
public void setCount(int count)
Sets the number of matches found or replaced. For regular "find" and "replace" operations, this should be zero or1
. For "replace all" operations, this should be the number of replacements. For "mark all" operations, this should be zero.- Parameters:
count
- The count.- See Also:
getCount()
-
setMarkedCount
public void setMarkedCount(int markedCount)
Sets the number of marked occurrences found.- Parameters:
markedCount
- The number of marked occurrences found.- See Also:
getMarkedCount()
-
setMatchRange
public void setMatchRange(DocumentRange range)
Sets the selected range for this search operation.- Parameters:
range
- The new selected range.- See Also:
getMatchRange()
-
toString
public String toString()
Returns a string representation of this object. Useful for debugging.
-
wasFound
public boolean wasFound()
Returns whether anything was found in this search operation. This is shorthand forgetCount()>0
.- Returns:
- Whether anything was found in this search operation.
- See Also:
getCount()
-
-