Class 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 Detail

      • forFormat

        @Nonnull
        public static java.util.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.
      • readSelect

        @Nonnull
        public static SelectQueryResult readSelect​(@Nonnull
                                                   java.nio.file.Path thePath)
                                            throws java.io.IOException
        Return the query 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 type
        InvalidQueryResults - If the query results encoded in the file are not valid
        java.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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        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 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:
        java.io.IOException - if there is an error opening or reading from the file
        InvalidQueryResults - if the results were invalid wrt to the format
        java.lang.IllegalArgumentException - if there is no known parser for the `QueryResultFormat`