Package org.eclipse.rdf4j.console.util
Class ConsoleQueryResultWriter
java.lang.Object
org.eclipse.rdf4j.query.resultio.AbstractQueryResultWriter
org.eclipse.rdf4j.console.util.ConsoleQueryResultWriter
- All Implemented Interfaces:
Sink
,QueryResultHandler
,QueryResultWriter
Write query results to console
- Author:
- Bart Hanssens
-
Constructor Summary
ConstructorDescriptionConsoleQueryResultWriter(ConsoleIO consoleIO, int consoleWidth)
Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicates the end of the header.void
Indicates the end of a sequence of solutions.Gets the query result format that this writer uses.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
handleNamespace(String prefix, String uri)
Handles a namespace prefix declaration.protected void
handleSolutionImpl(BindingSet bindingSet)
Extending classes must implement this method instead of overridingAbstractQueryResultWriter.handleSolution(BindingSet)
in order to benefit from automatic handling of RDF-star encoding.void
handleStylesheet(String stylesheetUrl)
Handles a stylesheet URL.void
Indicates the start of the document.void
Indicates the start of the header.void
startQueryResult(List<String> bindingNames)
Indicates the start of a sequence of Solutions.Methods inherited from class org.eclipse.rdf4j.query.resultio.AbstractQueryResultWriter
getFileFormat, getSupportedSettings, getWriterConfig, handleSolution, setWriterConfig, xsdStringToPlainLiteral
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.common.io.Sink
acceptsFileFormat
-
Constructor Details
-
ConsoleQueryResultWriter
Constructor- Parameters:
consoleIO
-consoleWidth
- console width
-
-
Method Details
-
getQueryResultFormat
Description copied from interface:QueryResultWriter
Gets the query result format that this writer uses. -
handleNamespace
Description copied from interface:QueryResultWriter
Handles a namespace prefix declaration. If this is called, it should be called beforeQueryResultWriter.startDocument()
to ensure that it has a document wide effect.NOTE: If the format does not support namespaces, it must silently ignore calls to this method.
- Parameters:
prefix
- The prefix to use for the namespaceuri
- The full URI that is to be represented by the prefix.- Throws:
QueryResultHandlerException
-
startDocument
Description copied from interface:QueryResultWriter
Indicates the start of the document.- Throws:
QueryResultHandlerException
- If there was an error starting the writing of the results.
-
handleStylesheet
Description copied from interface:QueryResultWriter
Handles a stylesheet URL. If this is called, it must be called afterQueryResultWriter.startDocument()
and beforeQueryResultWriter.startHeader()
.NOTE: If the format does not support stylesheets, it must silently ignore calls to this method.
- Parameters:
stylesheetUrl
- The URL of the stylesheet to be used to style the results.- Throws:
QueryResultHandlerException
- If there was an error handling the stylesheet. This error is not thrown in cases where stylesheets are not supported.
-
startHeader
Description copied from interface:QueryResultWriter
Indicates the start of the header.- Throws:
QueryResultHandlerException
- If there was an error writing the start of the header.- See Also:
- SPARQL Query Results XML Format documentation for head element.
-
endHeader
Description copied from interface:QueryResultWriter
Indicates the end of the header. This must be called afterQueryResultWriter.startHeader()
and before any calls toQueryResultHandler.handleSolution(org.eclipse.rdf4j.query.BindingSet)
.- Throws:
QueryResultHandlerException
- If there was an error writing the end of the header.
-
handleBoolean
Description copied from interface:QueryResultHandler
Handles the specified boolean value.- 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.
-
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.
- 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:
- "link"
-
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
- Overrides:
startQueryResult
in classAbstractQueryResultWriter
- 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.
-
endQueryResult
Description copied from interface:QueryResultHandler
Indicates the end of a sequence of solutions.- 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.
-
handleSolutionImpl
Description copied from class:AbstractQueryResultWriter
Extending classes must implement this method instead of overridingAbstractQueryResultWriter.handleSolution(BindingSet)
in order to benefit from automatic handling of RDF-star encoding.- Overrides:
handleSolutionImpl
in classAbstractQueryResultWriter
- Parameters:
bindingSet
- the solution to handle- Throws:
TupleQueryResultHandlerException
-