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 CCursor to traverse input collection.Predicate function for testing elements.protected FilterDataData which element must match to. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRepositionTo(TElement element) Checks if search can be repositioned to given element.booleanGets 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).booleanChecks if searcher not traversed to the end of the input and next element is given.booleanChecks if searcher not traversed to the beginning of the input and previous element is given.protected abstract CGets 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).voidInitializes searcher by specified container to search in.voidrepositionTo(TElement element) Repositions to specific element.Repositions to next element.Repositions to prev element.voidStarts searching from the beginning of data.voidStarts searching from the end of data.voidResets search progress to start searching again.search()Searches forward.Searches backward.voidsetFilterData(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, waitMethods 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:ISearcherInitializes searcher by specified container to search in. -
getFilterData
Description copied from interface:ISearcherGets current filter data.- Specified by:
getFilterDatain interfaceISearcher<TElement>- Returns:
- the current filter data, can be
null
-
setFilterData
Description copied from interface:ISearcherSets the filter data for searching.- Specified by:
setFilterDatain interfaceISearcher<TElement>- Parameters:
filterData- the filter data for searching, cannot benull
-
canSearch
public boolean canSearch()Description copied from interface:ISearcherGets 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:ISearcherSearches forward. -
searchBack
Description copied from interface:ISearcherSearches backward.- Specified by:
searchBackin interfaceISearcher<TElement>- Returns:
- the found element, may be
nullif matching element not found
-
repositionToTheBeginning
public void repositionToTheBeginning()Description copied from interface:ISearcherStarts searching from the beginning of data.- Specified by:
repositionToTheBeginningin interfaceISearcher<TElement>
-
repositionTo
Description copied from interface:ISearcherRepositions to specific element.- Specified by:
repositionToin interfaceISearcher<TElement>- Parameters:
element- the element to which to reposition, cannot benull
-
resetSearch
public void resetSearch()Description copied from interface:ISearcherResets search progress to start searching again.- Specified by:
resetSearchin interfaceISearcher<TElement>
-
repositionToNextElement
Description copied from interface:ISearcherRepositions to next element.- Specified by:
repositionToNextElementin interfaceISearcher<TElement>- Returns:
- next element, never
null
-
repositionToPrevElement
Description copied from interface:ISearcherRepositions to prev element.- Specified by:
repositionToPrevElementin interfaceISearcher<TElement>- Returns:
- prev element, never
null
-
repositionToTheEnd
public void repositionToTheEnd()Description copied from interface:ISearcherStarts searching from the end of data.- Specified by:
repositionToTheEndin interfaceISearcher<TElement>
-
canSearchPrev
public boolean canSearchPrev()Description copied from interface:ISearcherChecks if searcher not traversed to the beginning of the input and previous element is given.- Specified by:
canSearchPrevin interfaceISearcher<TElement>- Returns:
falsecurrent element is the first one in collection or reached beginning of data,trueotherwise
-
canSearchNext
public boolean canSearchNext()Description copied from interface:ISearcherChecks if searcher not traversed to the end of the input and next element is given.- Specified by:
canSearchNextin interfaceISearcher<TElement>- Returns:
falsecurrent element is the last one in collection or reached end of data,trueotherwise
-
canRepositionTo
Description copied from interface:ISearcherChecks if search can be repositioned to given element. Searcher can be repositioned to given element, if element is present in input.- Specified by:
canRepositionToin interfaceISearcher<TElement>- Parameters:
element- the element to reposition searcher to, cannot benull- Returns:
trueif repositioning is possible,falseotherwise
-
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
nullthen preserving will not happened.
-