Package org.dspace.discovery
Class DiscoverResultIterator<T extends ReloadableEntity,PK extends Serializable>
java.lang.Object
org.dspace.discovery.DiscoverResultIterator<T,PK>
- Type Parameters:
T- the type of the indexed objectPK- the type of the id of the indexed object
- All Implemented Interfaces:
Iterator<T>
- Direct Known Subclasses:
DiscoverResultItemIterator
public class DiscoverResultIterator<T extends ReloadableEntity,PK extends Serializable>
extends Object
implements Iterator<T>
Implementation of
Iterator to iterate over the discover search result.- Author:
- Luca Giamminonni (luca.giamminonni at 4science.it)
-
Constructor Summary
ConstructorsConstructorDescriptionDiscoverResultIterator(Context context, DiscoverQuery discoverQuery) Constructor for global search without scope and unlimited results.DiscoverResultIterator(Context context, DiscoverQuery discoverQuery, boolean uncacheEntities) Constructor with optional uncacheEntities flag.DiscoverResultIterator(Context context, IndexableObject<?, ?> scopeObject, DiscoverQuery discoverQuery) Constructor for scoped search without a limit on the number of results.DiscoverResultIterator(Context context, IndexableObject<?, ?> scopeObject, DiscoverQuery discoverQuery, boolean uncacheEntities, int maxResults) Full constructor with all options. -
Method Summary
Modifier and TypeMethodDescriptionprotected IndexableObjectRetrieves the next indexable object.longReturns the total number of search results.booleanhasNext()Checks if there are more elements to iterate over.next()Returns the next element in the iteration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
DiscoverResultIterator
Constructor for global search without scope and unlimited results. -
DiscoverResultIterator
public DiscoverResultIterator(Context context, DiscoverQuery discoverQuery, boolean uncacheEntities) Constructor with optional uncacheEntities flag. -
DiscoverResultIterator
public DiscoverResultIterator(Context context, IndexableObject<?, ?> scopeObject, DiscoverQuery discoverQuery) Constructor for scoped search without a limit on the number of results. -
DiscoverResultIterator
public DiscoverResultIterator(Context context, IndexableObject<?, ?> scopeObject, DiscoverQuery discoverQuery, boolean uncacheEntities, int maxResults) Full constructor with all options.
-
-
Method Details
-
hasNext
public boolean hasNext()Checks if there are more elements to iterate over. If the maximum number of results has been reached, it returns false. Otherwise, it checks the current slot iterator or fetches the next batch of results.- Specified by:
hasNextin interfaceIterator<T extends ReloadableEntity>- Returns:
- true if there are more elements, false otherwise
-
next
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<T extends ReloadableEntity>
-
getTotalSearchResults
public long getTotalSearchResults()Returns the total number of search results.This method calculates the total number of search results based on the current search query. If the slot iterator has not been initialized, it updates the iterator.
- Returns:
- the total number of search results as a
long
-
getNextIndexableObject
Retrieves the next indexable object. Throws NoSuchElementException if there are no more elements.
-