Package com.stardog.stark.query.io
Class QueryResultParsers
java.lang.Object
com.stardog.stark.query.io.QueryResultParsers
Utilities for working with query results
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<BooleanQueryResultParser> forBooleanFormat(QueryResultFormat theFormat) static Optional<QueryResultParser> forFormat(QueryResultFormat theFormat) Return theparserassociated with the given format.static Optional<SelectQueryResultParser> forSelectFormat(QueryResultFormat theFormat) static <T> QueryResult<T> read(InputStream theStream, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler) Parse thequery resultsin the specified filestatic <T> QueryResult<T> read(InputStream theStream, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler) Parse thequery resultsin the specified filestatic <T> QueryResult<T> read(Path thePath, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler) Parse thequery resultsin the specified filestatic <T> QueryResult<T> read(Path thePath, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler) Parse thequery resultsin the specified filestatic booleanreadBoolean(InputStream theStream, QueryResultFormat theFormat) Parse thequery resultsin the specified streamstatic SelectQueryResultreadSelect(InputStream theStream, QueryResultFormat theFormat) Parse thequery resultsin the specified streamstatic SelectQueryResultreadSelect(Path thePath) Return thequery resultsserialized in the given filestatic SelectQueryResultreadSelectAsync(InputStream theStream, ExecutorService theExecutorService, QueryResultFormat theFormat, int batchSize, CancelCheck cancelCheck, Consumer<Boolean> onClose, Function<Exception, RuntimeException> onError)
-
Method Details
-
forFormat
Return theparserassociated 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.XMLsupport 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 Optional<SelectQueryResultParser> forSelectFormat(@Nonnull QueryResultFormat theFormat) -
forBooleanFormat
@Nonnull public static Optional<BooleanQueryResultParser> forBooleanFormat(@Nonnull QueryResultFormat theFormat) -
readSelect
Return thequery resultsserialized in the given file- Parameters:
thePath- the file to read- Returns:
- the results
- Throws:
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 validIOException- If there was an error opening or reading from the file
-
readSelect
@Nonnull public static SelectQueryResult readSelect(@Nonnull InputStream theStream, @Nonnull QueryResultFormat theFormat) throws IOException Parse thequery resultsin the specified stream- Parameters:
theStream- the streams whose contents should be parsedtheFormat- the format of the file- Returns:
- the result
- Throws:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
readSelectAsync
public static SelectQueryResult readSelectAsync(@Nonnull InputStream theStream, @Nonnull ExecutorService theExecutorService, @Nonnull QueryResultFormat theFormat, @Nonnull int batchSize, @Nonnull CancelCheck cancelCheck, @Nonnull Consumer<Boolean> onClose, @Nonnull Function<Exception, RuntimeException> onError) -
readBoolean
public static boolean readBoolean(@Nonnull InputStream theStream, @Nonnull QueryResultFormat theFormat) throws IOException Parse thequery resultsin the specified stream- Parameters:
theStream- the streams whose contents should be parsedtheFormat- the format of the file- Returns:
- the result
- Throws:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull Path thePath, @Nonnull QueryResultFormat theFormat, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws IOException Parse thequery resultsin 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:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull InputStream theStream, @Nonnull QueryResultFormat theFormat, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws IOException Parse thequery resultsin 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:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull Path thePath, @Nonnull QueryResultParser theParser, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws IOException Parse thequery resultsin 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:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
read
@Nonnull public static <T> QueryResult<T> read(@Nonnull InputStream theStream, @Nonnull QueryResultParser theParser, @Nonnull Options theOptions, @Nonnull QueryResultBuilder<T> theHandler) throws IOException Parse thequery resultsin 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:
IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatIllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-