Class SRUSearchResultSet


  • public abstract class SRUSearchResultSet
    extends Object
    A result set of a searchRetrieve operation. It it used to iterate over the result set and provides a method to serialize the record in the requested format.

    A SRUSearchResultSet object maintains a cursor pointing to its current record. Initially the cursor is positioned before the first record. The next method moves the cursor to the next record, and because it returns false when there are no more records in the SRUSearchResultSet object, it can be used in a while loop to iterate through the result set.

    This class needs to be implemented for the target search engine.

    See Also:
    SRU Search Retrieve Operation
    • Constructor Detail

      • SRUSearchResultSet

        protected SRUSearchResultSet​(SRUDiagnosticList diagnostics)
        Constructor.
        Parameters:
        diagnostics - an instance of a SRUDiagnosticList
        See Also:
        SRUDiagnosticList
    • Method Detail

      • getTotalRecordCount

        public abstract int getTotalRecordCount()
        The number of records matched by the query. If the query fails this must be 0. If the search engine cannot determine the total number of matched by a query, it must return -1.
        Returns:
        the total number of results or 0 if the query failed or -1 if the search engine cannot determine the total number of results
      • getRecordCount

        public abstract int getRecordCount()
        The number of records matched by the query but at most as the number of records requested to be returned (maximumRecords parameter). If the query fails this must be 0.
        Returns:
        the number of results or 0 if the query failed
      • getResultSetId

        public String getResultSetId()
        The result set id of this result. the default implementation returns null.
        Returns:
        the result set id or null if not applicable for this result
      • getResultSetTTL

        public int getResultSetTTL()
        The result set time to live. In SRU 2.0 it will be serialized as <resultSetTTL> element; in SRU 1.2 as <resultSetIdleTime> element.The default implementation returns -1.
        Returns:
        the result set time to live or -1 if not applicable for this result
      • getResultCountPrecision

        public SRUResultCountPrecision getResultCountPrecision()
        (SRU 2.0) Indicate the accuracy of the result count reported by total number of records that matched the query. Default implementation returns null.
        Returns:
        the result count precision or null if not applicable for this result
        See Also:
        SRUResultCountPrecision
      • getRecordSchemaIdentifier

        public abstract String getRecordSchemaIdentifier()
        The record schema identifier in which the records are returned (recordSchema parameter).
        Returns:
        the record schema identifier
      • nextRecord

        public abstract boolean nextRecord()
                                    throws SRUException
        Moves the cursor forward one record from its current position. A SRUSearchResultSet cursor is initially positioned before the first record; the first call to the method next makes the first record the current record; the second call makes the second record the current record, and so on.

        When a call to the next method returns false, the cursor is positioned after the last record.

        Returns:
        true if the new current record is valid; false if there are no more records
        Throws:
        SRUException - if an error occurred while fetching the next record
      • getRecordIdentifier

        public abstract String getRecordIdentifier()
        An identifier for the current record by which it can unambiguously be retrieved in a subsequent operation.
        Returns:
        identifier for the record or null of none is available
        Throws:
        NoSuchElementException - result set is past all records
      • getSurrogateDiagnostic

        public SRUDiagnostic getSurrogateDiagnostic()
        Get surrogate diagnostic for current record. If this method returns a diagnostic, the writeRecord method will not be called. The default implementation returns null.
        Returns:
        a surrogate diagnostic or null
      • hasExtraRecordData

        public boolean hasExtraRecordData()
        Check, if extra record data should be serialized for the current record. The default implementation returns false.
        Returns:
        true if the record has extra record data
        Throws:
        NoSuchElementException - result set is already advanced past all records
        See Also:
        writeExtraResponseData(XMLStreamWriter)
      • addDiagnostic

        protected final void addDiagnostic​(String uri,
                                           String details,
                                           String message)
        Add a non surrogate diagnostic to the response.
        Parameters:
        uri - the diagnostic's identifying URI
        details - supplementary information available, often in a format specified by the diagnostic or null
        message - human readable message to display to the end user or null
      • addDiagnostic

        protected final void addDiagnostic​(String uri,
                                           String details)
        Add a non surrogate diagnostic to the response.
        Parameters:
        uri - the diagnostic's identifying URI
        details - supplementary information available, often in a format specified by the diagnostic or null
      • addDiagnostic

        protected final void addDiagnostic​(String uri)
        Add a non surrogate diagnostic to the response.
        Parameters:
        uri - the diagnostic's identifying URI
      • hasExtraResponseData

        public boolean hasExtraResponseData()
        Check, if extra response data should be serialized for this request. Default implementation is provided for convince and always returns false.
        Returns:
        true if extra response data should be serialized.
        See Also:
        writeExtraResponseData(XMLStreamWriter)
      • close

        public void close()
        Release this result and free any associated resources.

        This method must not throw any exceptions

        Calling the method close on a result object that is already closed is a no-op.