Class QueryResultCollector
java.lang.Object
org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector
- All Implemented Interfaces:
BooleanQueryResultHandler
,QueryResultHandler
,TupleQueryResultHandler
public class QueryResultCollector
extends Object
implements TupleQueryResultHandler, BooleanQueryResultHandler
An implementation of the
QueryResultHandler
interface that is able to collect a single result from either
Boolean or Tuple results simultaneously.
The List
s that are returned by this interface are immutable.
- Author:
- Peter Ansell
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicates the end of a sequence of solutions.Returns a collection of binding names collected.boolean
IfgetHandledBoolean()
returns true this method returns the boolean that was last found usinghandleBoolean(boolean)
boolean
Determines whetherhandleBoolean(boolean)
was called for this collector.boolean
Determines whetherendQueryResult()
was called after the last calls tostartQueryResult(List)
and optionally calls tohandleSolution(BindingSet)
.getLinks()
void
handleBoolean
(boolean value) Handles the specified boolean value.void
handleLinks
(List<String> linkUrls) Handles the links elements which are present in SPARQL Results JSON and SPARQL Results XML documents in the header.void
handleSolution
(BindingSet bindingSet) Handles a solution.void
startQueryResult
(List<String> bindingNames) Indicates the start of a sequence of Solutions.
-
Constructor Details
-
QueryResultCollector
public QueryResultCollector()
-
-
Method Details
-
handleBoolean
Description copied from interface:QueryResultHandler
Handles the specified boolean value.- Specified by:
handleBoolean
in interfaceQueryResultHandler
- Parameters:
value
- The boolean value to handle.- Throws:
QueryResultHandlerException
- If there was an error during the handling of this value. This exception may be thrown if theQueryResultHandler.startQueryResult(List)
,QueryResultHandler.handleSolution(BindingSet)
orQueryResultHandler.endQueryResult()
methods were called before this method was called, and the handler cannot process both boolean and tuple results simultaneously.
-
startQueryResult
Description copied from interface:QueryResultHandler
Indicates the start of a sequence of Solutions. The supplied bindingNames are an indication of the values that are in the Solutions. For example, a SPARQL query like select ?X ?Y where { ?X ?P ?Y } will have binding names X and Y.- Specified by:
startQueryResult
in interfaceQueryResultHandler
- Parameters:
bindingNames
- An ordered set of binding names.- Throws:
TupleQueryResultHandlerException
- If there was an error during the starting of the query result handler. This exception may be thrown if theQueryResultHandler.handleBoolean(boolean)
method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
-
handleSolution
Description copied from interface:QueryResultHandler
Handles a solution.- Specified by:
handleSolution
in interfaceQueryResultHandler
- Parameters:
bindingSet
- A single set of tuple results, with binding names bound to values. Each of the binding names in the solution must have previously been registered with theQueryResultHandler.startQueryResult(List)
method.- Throws:
TupleQueryResultHandlerException
- If there was an error during the handling of the query solution. This exception may be thrown if theQueryResultHandler.handleBoolean(boolean)
method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
-
endQueryResult
Description copied from interface:QueryResultHandler
Indicates the end of a sequence of solutions.- Specified by:
endQueryResult
in interfaceQueryResultHandler
- Throws:
TupleQueryResultHandlerException
- If there was an error during the ending of the query result handler. This exception may be thrown if theQueryResultHandler.handleBoolean(boolean)
method was called before this method and the handler cannot process both boolean and tuple results simultaneously.
-
handleLinks
Description copied from interface:QueryResultHandler
Handles the links elements which are present in SPARQL Results JSON and SPARQL Results XML documents in the header.NOTE: If the format does not support links, it must silently ignore a call to this method.
An accumulating handler should accumulate these links.
- Specified by:
handleLinks
in interfaceQueryResultHandler
- Parameters:
linkUrls
- The URLs of the links to handle.- Throws:
QueryResultHandlerException
- If there was an error handling the set of link URLs. This error is not thrown in cases where links are not supported.- See Also:
-
getHandledBoolean
public boolean getHandledBoolean()Determines whetherhandleBoolean(boolean)
was called for this collector.- Returns:
- True if there was a boolean handled by this collector.
-
getBoolean
IfgetHandledBoolean()
returns true this method returns the boolean that was last found usinghandleBoolean(boolean)
If
getHandledBoolean()
returns false this method throws aQueryResultHandlerException
indicating that a response could not be provided.- Returns:
- The boolean value that was collected.
- Throws:
QueryResultHandlerException
- If there was no boolean value collected.
-
getHandledTuple
public boolean getHandledTuple()Determines whetherendQueryResult()
was called after the last calls tostartQueryResult(List)
and optionally calls tohandleSolution(BindingSet)
.- Returns:
- True if there was a call to
endQueryResult()
after the last calls tostartQueryResult(List)
andhandleSolution(BindingSet)
.
-
getBindingNames
Returns a collection of binding names collected.- Returns:
- An immutable list of
String
s that were collected as the binding names. - Throws:
QueryResultHandlerException
- If the tuple results set was not successfully collected, as signalled by a call toendQueryResult()
.
-
getBindingSets
- Returns:
- An immutable list of
BindingSet
s that were collected as the tuple results. - Throws:
QueryResultHandlerException
- If the tuple results set was not successfully collected, as signalled by a call toendQueryResult()
.
-
getLinks
- Returns:
- A list of links accumulated from calls to
handleLinks(List)
.
-