Package com.stardog.stark.query.io
Class QueryResultParsers
- java.lang.Object
-
- com.stardog.stark.query.io.QueryResultParsers
-
public final class QueryResultParsers extends java.lang.Object
Utilities for working with
query results
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<BooleanQueryResultParser>
forBooleanFormat(QueryResultFormat theFormat)
static java.util.Optional<QueryResultParser>
forFormat(QueryResultFormat theFormat)
Return theparser
associated with the given format.static java.util.Optional<SelectQueryResultParser>
forSelectFormat(QueryResultFormat theFormat)
static <T> QueryResult<T>
read(java.io.InputStream theStream, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler)
Parse thequery results
in the specified filestatic <T> QueryResult<T>
read(java.io.InputStream theStream, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)
Parse thequery results
in the specified filestatic <T> QueryResult<T>
read(java.nio.file.Path thePath, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler)
Parse thequery results
in the specified filestatic <T> QueryResult<T>
read(java.nio.file.Path thePath, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)
Parse thequery results
in the specified filestatic boolean
readBoolean(java.io.InputStream theStream, QueryResultFormat theFormat)
Parse thequery results
in the specified streamstatic SelectQueryResult
readSelect(java.io.InputStream theStream, QueryResultFormat theFormat)
Parse thequery results
in the specified streamstatic SelectQueryResult
readSelect(java.nio.file.Path thePath)
Return thequery results
serialized in the given filestatic SelectQueryResult
readSelectAsync(java.io.InputStream theStream, java.util.concurrent.ExecutorService theExecutorService, QueryResultFormat theFormat, int batchSize, CancelCheck cancelCheck, java.lang.Runnable onClose, java.util.function.Function<java.lang.Exception,java.lang.RuntimeException> onError)
-
-
-
Method Detail
-
forFormat
@Nonnull public static java.util.Optional<QueryResultParser> forFormat(@Nonnull QueryResultFormat theFormat)
Return theparser
associated with the given format.- Parameters:
theFormat
- the format you wish to parse- Returns:
- the parser for the format
- Implementation Notes:
- This will return the *first* parser which supports the format. Since some formats, most notable
QueryResultFormats.XML
support both select and boolean result types, you could end up with the wrong parser given your use case. If you need a specific parser type, use the appropriate method.
-
forSelectFormat
@Nonnull public static java.util.Optional<SelectQueryResultParser> forSelectFormat(@Nonnull QueryResultFormat theFormat)
-
forBooleanFormat
@Nonnull public static java.util.Optional<BooleanQueryResultParser> forBooleanFormat(@Nonnull QueryResultFormat theFormat)
-
readSelect
@Nonnull public static SelectQueryResult readSelect(@Nonnull java.nio.file.Path thePath) throws java.io.IOException
Return thequery results
serialized in the given file- Parameters:
thePath
- the file to read- Returns:
- the results
- Throws:
java.lang.IllegalArgumentException
- If the format of the file is unknown, or there is no parser that supports files of that typeInvalidQueryResults
- If the query results encoded in the file are not validjava.io.IOException
- If there was an error opening or reading from the file
-
readSelect
@Nonnull public static SelectQueryResult readSelect(@Nonnull java.io.InputStream theStream, @Nonnull QueryResultFormat theFormat) throws java.io.IOException
Parse thequery results
in the specified stream- Parameters:
theStream
- the streams whose contents should be parsedtheFormat
- the format of the file- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
readSelectAsync
public static SelectQueryResult readSelectAsync(@Nonnull java.io.InputStream theStream, @Nonnull java.util.concurrent.ExecutorService theExecutorService, @Nonnull QueryResultFormat theFormat, @Nonnull int batchSize, @Nonnull CancelCheck cancelCheck, @Nonnull java.lang.Runnable onClose, @Nonnull java.util.function.Function<java.lang.Exception,java.lang.RuntimeException> onError)
-
readBoolean
public static boolean readBoolean(@Nonnull java.io.InputStream theStream, @Nonnull QueryResultFormat theFormat) throws java.io.IOException
Parse thequery results
in the specified stream- Parameters:
theStream
- the streams whose contents should be parsedtheFormat
- the format of the file- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull java.nio.file.Path thePath, @Nonnull QueryResultFormat theFormat, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws java.io.IOException
Parse thequery results
in the specified file- Parameters:
thePath
- the file whose contents should be parsetheFormat
- the format of the filetheOptions
- the parser optionstheHandler
- the handler of the parsed results- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull java.io.InputStream theStream, @Nonnull QueryResultFormat theFormat, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws java.io.IOException
Parse thequery results
in the specified file- Parameters:
theStream
- the streams whose contents should be parsedtheFormat
- the format of the filetheOptions
- the parser optionstheHandler
- the handler of the parsed results- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull java.nio.file.Path thePath, @Nonnull QueryResultParser theParser, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws java.io.IOException
Parse thequery results
in the specified file- Parameters:
thePath
- the file whose contents should be parsedtheParser
- the parser to usetheOptions
- the parser optionstheHandler
- the handler of the parsed results- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull java.io.InputStream theStream, @Nonnull QueryResultParser theParser, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws java.io.IOException
Parse thequery results
in the specified file- Parameters:
theStream
- the streams whose contents should be parsedtheParser
- the parser to usetheOptions
- the parser optionstheHandler
- the handler of the parsed results- Returns:
- the result
- Throws:
java.io.IOException
- if there is an error opening or reading from the fileInvalidQueryResults
- if the results were invalid wrt to theformat
java.lang.IllegalArgumentException
- if there is no known parser for the `QueryResultFormat`
-
-