Package eu.clarin.sru.server
Class SRUScanResultSet
- java.lang.Object
-
- eu.clarin.sru.server.SRUScanResultSet
-
public abstract class SRUScanResultSet extends Object
A result set of a scan operation. It is used to iterate over the term set and provides a method to serialize the terms.A
SRUScanResultSet
object maintains a cursor pointing to its current term. Initially the cursor is positioned before the first term. Thenext
method moves the cursor to the next term, and because it returnsfalse
when there are no more terms in theSRUScanResultSet
object, it can be used in awhile
loop to iterate through the term set.This class needs to be implemented for the target search engine.
- See Also:
- SRU Scan Operation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SRUScanResultSet.WhereInList
A flag to indicate the position of the term within the complete term list.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SRUScanResultSet(SRUDiagnosticList diagnostics)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addDiagnostic(String uri)
Add a non surrogate diagnostic to the response.protected void
addDiagnostic(String uri, String details)
Add a non surrogate diagnostic to the response.protected void
addDiagnostic(String uri, String details, String message)
Add a non surrogate diagnostic to the response.void
close()
Release this result and free any associated resources.abstract String
getDisplayTerm()
Get the string for the current term to display to the end user in place of the term itself.abstract int
getNumberOfRecords()
Get the number of records for the current term which would be matched if the index in the request's scanClause was searched with the term in the value field.abstract String
getValue()
Get the current term exactly as it appears in the index.abstract SRUScanResultSet.WhereInList
getWhereInList()
Get the flag to indicate the position of the term within the complete term list.boolean
hasExtraResponseData()
Check, if extra response data should be serialized for this request.boolean
hasExtraTermData()
Check, if extra term data should be serialized for the current term.abstract boolean
nextTerm()
Moves the cursor forward one term from its current position.void
writeExtraResponseData(XMLStreamWriter writer)
Serialize extra response data for this request.void
writeExtraTermData(XMLStreamWriter writer)
Serialize extra term data for the current term.
-
-
-
Constructor Detail
-
SRUScanResultSet
protected SRUScanResultSet(SRUDiagnosticList diagnostics)
Constructor.- Parameters:
diagnostics
- an instance of a SRUDiagnosticList.- See Also:
SRUDiagnosticList
-
-
Method Detail
-
nextTerm
public abstract boolean nextTerm() throws SRUException
Moves the cursor forward one term from its current position. A result set cursor is initially positioned before the first record; the first call to the methodnext
makes the first term the current term; the second call makes the second term the current term, and so on.When a call to the
next
method returnsfalse
, the cursor is positioned after the last term.- Returns:
true
if the new current term is valid;false
if there are no more terms- Throws:
SRUException
- if an error occurred while fetching the next term
-
getValue
public abstract String getValue()
Get the current term exactly as it appears in the index.- Returns:
- current term
-
getNumberOfRecords
public abstract int getNumberOfRecords()
Get the number of records for the current term which would be matched if the index in the request's scanClause was searched with the term in the value field.- Returns:
- a non-negative number of records or
-1
, if the number is unknown.
-
getDisplayTerm
public abstract String getDisplayTerm()
Get the string for the current term to display to the end user in place of the term itself.- Returns:
- display string or
null
-
getWhereInList
public abstract SRUScanResultSet.WhereInList getWhereInList()
Get the flag to indicate the position of the term within the complete term list.- Returns:
- position within term list or
null
-
hasExtraTermData
public boolean hasExtraTermData()
Check, if extra term data should be serialized for the current term. A default implementation is provided for convince and always returnsfalse
.- Returns:
true
if the term has extra term data- Throws:
NoSuchElementException
- term set is already advanced past all past terms- See Also:
writeExtraTermData(XMLStreamWriter)
-
writeExtraTermData
public void writeExtraTermData(XMLStreamWriter writer) throws XMLStreamException
Serialize extra term data for the current term. A no-op default implementation is provided for convince.- Parameters:
writer
- theXMLStreamException
instance to be used- Throws:
XMLStreamException
- an error occurred while serializing the term extra dataNoSuchElementException
- result set already advanced past all terms- See Also:
hasExtraTermData()
-
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 URIdetails
- supplementary information available, often in a format specified by the diagnostic ornull
message
- human readable message to display to the end user ornull
-
addDiagnostic
protected final void addDiagnostic(String uri, String details)
Add a non surrogate diagnostic to the response.- Parameters:
uri
- the diagnostic's identifying URIdetails
- supplementary information available, often in a format specified by the diagnostic ornull
-
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 returnsfalse
.- Returns:
true
if extra response data should be serialized.- See Also:
writeExtraResponseData(XMLStreamWriter)
-
writeExtraResponseData
public void writeExtraResponseData(XMLStreamWriter writer) throws XMLStreamException
Serialize extra response data for this request.- Parameters:
writer
- theXMLStreamException
instance to be used- Throws:
XMLStreamException
- an error occurred while serializing the result- See Also:
hasExtraResponseData()
-
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.
-
-