Package com.stardog.stark.query.io

# Class QueryResultParsers

java.lang.Object
com.stardog.stark.query.io.QueryResultParsers

public final class QueryResultParsers extends Object

Utilities for working with `query results`

Since:
  1.0
Version:
  1.0
Author:
  Michael Grove

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Optional<BooleanQueryResultParser>`
  `forBooleanFormat(QueryResultFormat theFormat)`
  `static Optional<QueryResultParser>`
  `forFormat(QueryResultFormat theFormat)`
  Return the `parser` associated 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 the `query results` in the specified file
  `static <T> QueryResult<T>`
  `read(InputStream theStream, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)`
  Parse the `query results` in the specified file
  `static <T> QueryResult<T>`
  `read(Path thePath, QueryResultFormat theFormat, Options theOptions, QueryResultBuilder<T> theHandler)`
  Parse the `query results` in the specified file
  `static <T> QueryResult<T>`
  `read(Path thePath, QueryResultParser theParser, Options theOptions, QueryResultBuilder<T> theHandler)`
  Parse the `query results` in the specified file
  `static boolean`
  `readBoolean(InputStream theStream, QueryResultFormat theFormat)`
  Parse the `query results` in the specified stream
  `static SelectQueryResult`
  `readSelect(InputStream theStream, QueryResultFormat theFormat)`
  Parse the `query results` in the specified stream
  `static SelectQueryResult`
  `readSelect(Path thePath)`
  Return the `query results` serialized in the given file
  `static SelectQueryResult`
  `readSelectAsync(InputStream theStream, ExecutorService theExecutorService, QueryResultFormat theFormat, int batchSize, CancelCheck cancelCheck, Consumer<Boolean> onClose, Function<Exception,RuntimeException> onError)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### forFormat

    @Nonnull public static Optional<QueryResultParser> forFormat(@Nonnull QueryResultFormat theFormat)
    Return the `parser` 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 Optional<SelectQueryResultParser> forSelectFormat(@Nonnull QueryResultFormat theFormat)

  - ### forBooleanFormat

    @Nonnull public static Optional<BooleanQueryResultParser> forBooleanFormat(@Nonnull QueryResultFormat theFormat)

  - ### readSelect

    @Nonnull public static SelectQueryResult readSelect(@Nonnull Path thePath) throws IOException
    Return the `query results` serialized 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 type
      `InvalidQueryResults` - If the query results encoded in the file are not valid
      `IOException` - 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 the `query results` in the specified stream
    Parameters:
      `theStream` - the streams whose contents should be parsed
      `theFormat` - the format of the file
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - 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 the `query results` in the specified stream
    Parameters:
      `theStream` - the streams whose contents should be parsed
      `theFormat` - the format of the file
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - 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 the `query results` in the specified file
    Parameters:
      `thePath` - the file whose contents should be parse
      `theFormat` - the format of the file
      `theOptions` - the parser options
      `theHandler` - the handler of the parsed results
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - 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 the `query results` in the specified file
    Parameters:
      `theStream` - the streams whose contents should be parsed
      `theFormat` - the format of the file
      `theOptions` - the parser options
      `theHandler` - the handler of the parsed results
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - 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 the `query results` in the specified file
    Parameters:
      `thePath` - the file whose contents should be parsed
      `theParser` - the parser to use
      `theOptions` - the parser options
      `theHandler` - the handler of the parsed results
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - 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 the `query results` in the specified file
    Parameters:
      `theStream` - the streams whose contents should be parsed
      `theParser` - the parser to use
      `theOptions` - the parser options
      `theHandler` - the handler of the parsed results
    Returns:
      the result
    Throws:
      `IOException` - if there is an error opening or reading from the file
      `InvalidQueryResults` - if the results were invalid wrt to the `format`
      `IllegalArgumentException` - if there is no known parser for the `QueryResultFormat`