public class QueryResultIO extends Object
| Constructor and Description |
|---|
QueryResultIO() |
| Modifier and Type | Method and Description |
|---|---|
static BooleanQueryResultParser |
createBooleanParser(QueryResultFormat format)
Convenience methods for creating BooleanQueryResultParser objects.This method uses the registry returned by
BooleanQueryResultParserRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate parser. |
static BooleanQueryResultWriter |
createBooleanWriter(QueryResultFormat format,
OutputStream out)
Convenience methods for creating BooleanQueryResultWriter objects.This method uses the registry returned by
BooleanQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer. |
static TupleQueryResultParser |
createTupleParser(QueryResultFormat format)
Convenience methods for creating TupleQueryResultParser objects.
|
static TupleQueryResultParser |
createTupleParser(QueryResultFormat format,
ValueFactory valueFactory)
Convenience methods for creating TupleQueryResultParser objects that use the specified ValueFactory to create RDF
model objects.
|
static TupleQueryResultWriter |
createTupleWriter(QueryResultFormat format,
OutputStream out)
Convenience methods for creating TupleQueryResultWriter objects.This method uses the registry returned by
TupleQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer. |
static QueryResultWriter |
createWriter(QueryResultFormat format,
OutputStream out)
Convenience methods for creating QueryResultWriter objects.This method uses the registry returned by
TupleQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer. |
static Optional<QueryResultFormat> |
getBooleanParserFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be parsed.
|
static Optional<QueryResultFormat> |
getBooleanParserFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of boolean query result formats that can be parsed.
|
static Optional<QueryResultFormat> |
getBooleanWriterFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be written.
|
static Optional<QueryResultFormat> |
getBooleanWriterFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of boolean query result formats that can be written.
|
static Optional<QueryResultFormat> |
getParserFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be parsed.
|
static Optional<QueryResultFormat> |
getParserFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of tuple query result formats that can be parsed.
|
static Optional<QueryResultFormat> |
getWriterFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be written.
|
static Optional<QueryResultFormat> |
getWriterFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of tuple query result formats that can be written.
|
static boolean |
parseBoolean(InputStream in,
QueryResultFormat format)
Parses a boolean query result document and returns the parsed value.
|
static TupleQueryResult |
parseTuple(InputStream in,
QueryResultFormat format)
Parses a query result document and returns it as a TupleQueryResult object.
|
static void |
parseTuple(InputStream in,
QueryResultFormat format,
TupleQueryResultHandler handler,
ValueFactory valueFactory)
Parses a query result document, reporting the parsed solutions to the supplied TupleQueryResultHandler.
|
static TupleQueryResult |
parseTupleBackground(InputStream in,
QueryResultFormat format)
Parses a query result document and returns it as a TupleQueryResult object, with parsing done on a separate
thread in the background.
IMPORTANT: As this method may spawn a new thread in the background, it is vitally important that the TupleQueryResult be closed consistently when it is no longer required, to prevent resource leaks. |
static void |
writeBoolean(boolean value,
QueryResultFormat format,
OutputStream out)
Writes a boolean query result document in a specific boolean query result format to an output stream.
|
static void |
writeGraph(GraphQueryResult gqr,
RDFFormat format,
OutputStream out)
Writes a graph query result document in a specific RDF format to an output stream.
|
static void |
writeTuple(TupleQueryResult tqr,
QueryResultFormat format,
OutputStream out)
Writes a query result document in a specific query result format to an output stream.
|
public static Optional<QueryResultFormat> getParserFormatForMIMEType(String mimeType)
mimeType - A MIME type, e.g. "application/sparql-results+xml".Optional.empty() otherwise.public static Optional<QueryResultFormat> getParserFormatForFileName(String fileName)
fileName - A file name.Optional.empty() otherwise.public static Optional<QueryResultFormat> getWriterFormatForMIMEType(String mimeType)
mimeType - A MIME type, e.g. "application/sparql-results+xml".Optional.empty() otherwise.public static Optional<QueryResultFormat> getWriterFormatForFileName(String fileName)
fileName - A file name.Optional.empty() otherwise.public static Optional<QueryResultFormat> getBooleanParserFormatForMIMEType(String mimeType)
mimeType - A MIME type, e.g. "application/sparql-results+xml".Optional.empty() otherwise.public static Optional<QueryResultFormat> getBooleanParserFormatForFileName(String fileName)
fileName - A file name.Optional.empty() otherwise.public static Optional<QueryResultFormat> getBooleanWriterFormatForMIMEType(String mimeType)
mimeType - A MIME type, e.g. "application/sparql-results+xml".Optional.empty() otherwise.public static Optional<QueryResultFormat> getBooleanWriterFormatForFileName(String fileName)
fileName - A file name.Optional.empty() otherwise.public static TupleQueryResultParser createTupleParser(QueryResultFormat format) throws UnsupportedQueryResultFormatException
TupleQueryResultParserRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate parser.UnsupportedQueryResultFormatException - If no parser is available for the specified tuple query result
format.public static TupleQueryResultParser createTupleParser(QueryResultFormat format, ValueFactory valueFactory) throws UnsupportedQueryResultFormatException
format - valueFactory - UnsupportedQueryResultFormatException - If no parser is available for the specified tuple query result
format.QueryResultParser.setValueFactory(ValueFactory)public static TupleQueryResultWriter createTupleWriter(QueryResultFormat format, OutputStream out) throws UnsupportedQueryResultFormatException
TupleQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer.format - out - UnsupportedQueryResultFormatException - If no writer is available for the specified tuple query result
format.public static BooleanQueryResultParser createBooleanParser(QueryResultFormat format) throws UnsupportedQueryResultFormatException
BooleanQueryResultParserRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate parser.format - UnsupportedQueryResultFormatException - If no parser is available for the specified boolean query result
format.public static BooleanQueryResultWriter createBooleanWriter(QueryResultFormat format, OutputStream out) throws UnsupportedQueryResultFormatException
BooleanQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer.format - out - UnsupportedQueryResultFormatException - If no writer is available for the specified boolean query result
format.public static QueryResultWriter createWriter(QueryResultFormat format, OutputStream out) throws UnsupportedQueryResultFormatException
TupleQueryResultWriterRegistry.getInstance() to get a factory for the specified format and uses this
factory to create the appropriate writer.format - out - UnsupportedQueryResultFormatException - If no writer is available for the specified tuple query result
format.public static void parseTuple(InputStream in, QueryResultFormat format, TupleQueryResultHandler handler, ValueFactory valueFactory) throws IOException, QueryResultParseException, TupleQueryResultHandlerException, UnsupportedQueryResultFormatException
in - An InputStream to read the query result document from.format - The query result format of the document to parse. Supported formats are
TupleQueryResultFormat.SPARQL and TupleQueryResultFormat.BINARY.handler - The TupleQueryResultHandler to report the parse results to.valueFactory - IOException - If an I/O error occurred while reading the query result document
from the stream.TupleQueryResultHandlerException - If such an exception is thrown by the supplied
TupleQueryResultHandler.UnsupportedQueryResultFormatExceptionIllegalArgumentException - If an unsupported query result file format was specified.QueryResultParseExceptionpublic static TupleQueryResult parseTuple(InputStream in, QueryResultFormat format) throws IOException, QueryResultParseException, TupleQueryResultHandlerException, UnsupportedQueryResultFormatException
in - An InputStream to read the query result document from.format - The query result format of the document to parse. Supported formats are
TupleQueryResultFormat.SPARQL and TupleQueryResultFormat.BINARY.IOException - If an I/O error occurred while reading the query result document
from the stream.TupleQueryResultHandlerException - If such an exception is thrown by the used query result parser.UnsupportedQueryResultFormatExceptionIllegalArgumentException - If an unsupported query result file format was specified.QueryResultParseExceptionpublic static TupleQueryResult parseTupleBackground(InputStream in, QueryResultFormat format) throws IOException, QueryResultParseException, TupleQueryResultHandlerException, UnsupportedQueryResultFormatException
in - An InputStream to read the query result document from.format - The query result format of the document to parse. Supported formats are
TupleQueryResultFormat.SPARQL and TupleQueryResultFormat.BINARY.IOException - If an I/O error occurred while reading the query result document
from the stream.TupleQueryResultHandlerException - If such an exception is thrown by the used query result parser.UnsupportedQueryResultFormatExceptionIllegalArgumentException - If an unsupported query result file format was specified.QueryResultParseExceptionpublic static boolean parseBoolean(InputStream in, QueryResultFormat format) throws IOException, QueryResultParseException, UnsupportedQueryResultFormatException
in - An InputStream to read the query result document from.format - The file format of the document to parse.IOException - If an I/O error occurred while reading the query result document
from the stream.UnsupportedQueryResultFormatException - If an unsupported query result file format was specified.QueryResultParseExceptionpublic static void writeTuple(TupleQueryResult tqr, QueryResultFormat format, OutputStream out) throws IOException, TupleQueryResultHandlerException, UnsupportedQueryResultFormatException, QueryEvaluationException
tqr - The query result to write.format - The file format of the document to write.out - An OutputStream to write the document to.IOException - If an I/O error occurred while writing the query result document to
the stream.TupleQueryResultHandlerException - If such an exception is thrown by the used query result writer.UnsupportedQueryResultFormatExceptionQueryEvaluationException - If an unsupported query result file format was specified.public static void writeBoolean(boolean value,
QueryResultFormat format,
OutputStream out)
throws QueryResultHandlerException,
UnsupportedQueryResultFormatException
value - The value to write.format - The file format of the document to write.out - An OutputStream to write the document to.IOException - If an I/O error occurred while writing the query result document to
the stream.UnsupportedQueryResultFormatException - If an unsupported query result file format was specified.QueryResultHandlerExceptionpublic static void writeGraph(GraphQueryResult gqr, RDFFormat format, OutputStream out) throws IOException, RDFHandlerException, UnsupportedRDFormatException, QueryEvaluationException
gqr - The query result to write.format - The file format of the document to write.out - An OutputStream to write the document to.IOException - If an I/O error occurred while writing the query result document to the
stream.RDFHandlerException - If such an exception is thrown by the used RDF writer.QueryEvaluationExceptionUnsupportedRDFormatException - If an unsupported query result file format was specified.Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.