Package com.stardog.stark.query.io
Class QueryResultParsers
- java.lang.Object
-
- com.stardog.stark.query.io.QueryResultParsers
-
public final class QueryResultParsers extends java.lang.ObjectUtilities 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 theparserassociated 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 resultsin the specified filestatic <T> QueryResult<T>read(java.io.InputStream theStream, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)Parse thequery resultsin the specified filestatic <T> QueryResult<T>read(java.nio.file.Path thePath, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler)Parse thequery resultsin the specified filestatic <T> QueryResult<T>read(java.nio.file.Path thePath, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)Parse thequery resultsin the specified filestatic booleanreadBoolean(java.io.InputStream theStream, QueryResultFormat theFormat)Parse thequery resultsin the specified streamstatic SelectQueryResultreadSelect(java.io.InputStream theStream, QueryResultFormat theFormat)Parse thequery resultsin the specified streamstatic SelectQueryResultreadSelect(java.nio.file.Path thePath)Return thequery resultsserialized in the given filestatic SelectQueryResultreadSelectAsync(java.io.InputStream theStream, java.util.concurrent.ExecutorService theExecutorService, QueryResultFormat theFormat, int batchSize, CancelCheck cancelCheck, java.util.function.Consumer<java.lang.Boolean> 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 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 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 resultsserialized 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 resultsin 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 theformatjava.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.util.function.Consumer<java.lang.Boolean> 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.IOExceptionParse thequery resultsin 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 theformatjava.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 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:
java.io.IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatjava.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 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:
java.io.IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatjava.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 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:
java.io.IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatjava.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 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:
java.io.IOException- if there is an error opening or reading from the fileInvalidQueryResults- if the results were invalid wrt to theformatjava.lang.IllegalArgumentException- if there is no known parser for the `QueryResultFormat`
-
-