Package com._1c.g5.v8.dt.common.search
Class Searcher<TElement,C extends ICursor<TElement>>
java.lang.Object
com._1c.g5.v8.dt.common.search.Searcher<TElement,C>
- Type Parameters:
TElement
- type of collection elements
- All Implemented Interfaces:
ISearcher<TElement>
- Direct Known Subclasses:
AttributesSearcher
,BorderedSearcher
,FormCommandSearcher
,FormParameterSearcher
,ItemsSearcher
public abstract class Searcher<TElement,C extends ICursor<TElement>>
extends Object
implements ISearcher<TElement>
Represents an abstract generic two-directional searcher of elements with minimum required logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected C
Cursor to traverse input collection.Predicate function for testing elements.protected FilterData
Data which element must match to. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canRepositionTo
(TElement element) Checks if search can be repositioned to given element.boolean
Gets a value indicating whether the searching can be executed.
The searching can be executed if the filter was set from non-empty data; see ISearcher.setFilterData(FilterData).boolean
Checks if searcher not traversed to the end of the input and next element is given.boolean
Checks if searcher not traversed to the beginning of the input and previous element is given.protected abstract C
Gets cursor to navigate via the specified elements.getFilter
(FilterData filterData) Gets searching filter.Gets current filter data.getFilterToPreservePositionOf
(TElement oldElement) Executes on preserving the element position when initialization running init(List).void
Initializes searcher by specified container to search in.void
repositionTo
(TElement element) Repositions to specific element.Repositions to next element.Repositions to prev element.void
Starts searching from the beginning of data.void
Starts searching from the end of data.void
Resets search progress to start searching again.search()
Searches forward.Searches backward.void
setFilterData
(FilterData filterData) Sets the filter data for searching.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com._1c.g5.v8.dt.common.search.ISearcher
getElementType
-
Field Details
-
cursor
Cursor to traverse input collection. -
filter
Predicate function for testing elements. -
filterData
Data which element must match to.
-
-
Constructor Details
-
Searcher
public Searcher()
-
-
Method Details
-
init
Description copied from interface:ISearcher
Initializes searcher by specified container to search in. -
getFilterData
Description copied from interface:ISearcher
Gets current filter data.- Specified by:
getFilterData
in interfaceISearcher<TElement>
- Returns:
- the current filter data, can be
null
-
setFilterData
Description copied from interface:ISearcher
Sets the filter data for searching.- Specified by:
setFilterData
in interfaceISearcher<TElement>
- Parameters:
filterData
- the filter data for searching, cannot benull
-
canSearch
public boolean canSearch()Description copied from interface:ISearcher
Gets a value indicating whether the searching can be executed.
The searching can be executed if the filter was set from non-empty data; see ISearcher.setFilterData(FilterData). -
search
Description copied from interface:ISearcher
Searches forward. -
searchBack
Description copied from interface:ISearcher
Searches backward.- Specified by:
searchBack
in interfaceISearcher<TElement>
- Returns:
- the found element, may be
null
if matching element not found
-
repositionToTheBeginning
public void repositionToTheBeginning()Description copied from interface:ISearcher
Starts searching from the beginning of data.- Specified by:
repositionToTheBeginning
in interfaceISearcher<TElement>
-
repositionTo
Description copied from interface:ISearcher
Repositions to specific element.- Specified by:
repositionTo
in interfaceISearcher<TElement>
- Parameters:
element
- the element to which to reposition, cannot benull
-
resetSearch
public void resetSearch()Description copied from interface:ISearcher
Resets search progress to start searching again.- Specified by:
resetSearch
in interfaceISearcher<TElement>
-
repositionToNextElement
Description copied from interface:ISearcher
Repositions to next element.- Specified by:
repositionToNextElement
in interfaceISearcher<TElement>
- Returns:
- next element, never
null
-
repositionToPrevElement
Description copied from interface:ISearcher
Repositions to prev element.- Specified by:
repositionToPrevElement
in interfaceISearcher<TElement>
- Returns:
- prev element, never
null
-
repositionToTheEnd
public void repositionToTheEnd()Description copied from interface:ISearcher
Starts searching from the end of data.- Specified by:
repositionToTheEnd
in interfaceISearcher<TElement>
-
canSearchPrev
public boolean canSearchPrev()Description copied from interface:ISearcher
Checks if searcher not traversed to the beginning of the input and previous element is given.- Specified by:
canSearchPrev
in interfaceISearcher<TElement>
- Returns:
false
current element is the first one in collection or reached beginning of data,true
otherwise
-
canSearchNext
public boolean canSearchNext()Description copied from interface:ISearcher
Checks if searcher not traversed to the end of the input and next element is given.- Specified by:
canSearchNext
in interfaceISearcher<TElement>
- Returns:
false
current element is the last one in collection or reached end of data,true
otherwise
-
canRepositionTo
Description copied from interface:ISearcher
Checks if search can be repositioned to given element. Searcher can be repositioned to given element, if element is present in input.- Specified by:
canRepositionTo
in interfaceISearcher<TElement>
- Parameters:
element
- the element to reposition searcher to, cannot benull
- Returns:
true
if repositioning is possible,false
otherwise
-
getCursor
Gets cursor to navigate via the specified elements. Override this method to provide concrete cursor.- Parameters:
input
- the list of element to search in.- Returns:
- the navigation cursor as
ICursor
.
-
getFilter
Gets searching filter. Override this method to provide concrete filter.- Parameters:
filterData
- the filter data for searcher, can not benull
.- Returns:
- the filter as
Predicate
.
-
getFilterToPreservePositionOf
Executes on preserving the element position when initialization running init(List).- Parameters:
oldElement
- the old element which position need to preserve in new cursor, can not benull
.- Returns:
- the predicate for ability to preserve the old element position when initialization running. If
null
then preserving will not happened.
-