Class List Method List File List

# Class: VertxSqlClient::PreparedQuery

Inherits:
  Object
  - Object
  - VertxSqlClient::PreparedQuery
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb

## Overview

A prepared query.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) batch(argsList = nil) { ... }
  Execute a batch.
- - (void) close { ... }
  Like #close but notifies the completionHandler when it's closed.
- - (::VertxSqlClient::RowStream) create_stream(fetch = nil, args = nil)
  Execute the prepared query with a cursor and createStream the result.
- - (::VertxSqlClient::Cursor) cursor(args = nil)
  Create a cursor with the provided arguments.
- - (self) execute(args = nil) { ... }
  Create a cursor with the provided arguments.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    22
    23
    24
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 22

    def @@j_api_type.accept?(obj)
      obj.class == PreparedQuery
    end

### + (`Object`) j_api_type

    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 31

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 34

    def self.j_class
      Java::IoVertxSqlclient::PreparedQuery.java_class
    end

### + (`Object`) unwrap(obj)

    28
    29
    30
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 28

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 25

    def @@j_api_type.wrap(obj)
      PreparedQuery.new(obj)
    end

## Instance Method Details

### - (`self`) batch(argsList = nil) { ... }

Execute a batch.

Parameters:

- argsList (`Array<::VertxSqlClient::Tuple>`) (defaults to: `nil`) —
  the list of tuple for the batch

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 79

    def batch(argsList=nil)
      if argsList.class == Array && block_given?
        @j_del.java_method(:batch, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(argsList.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling batch(#{argsList})"
    end

### - (`void`) close { ... }

This method returns an undefined value.

Like #close but notifies the `completionHandler` when it's closed.

Yields:

Raises:

- (`ArgumentError`)

    89
    90
    91
    92
    93
    94
    95
    96
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 89

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      elsif block_given?
        return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`::VertxSqlClient::RowStream`) create_stream(fetch = nil, args = nil)

Execute the prepared query with a cursor and createStream the result. The createStream opens a cursor with a `fetch` size to fetch the results.

Note: this requires to be in a transaction, since cursors require it.

Parameters:

- fetch (`Fixnum`) (defaults to: `nil`) —
  the cursor fetch size
- args (`::VertxSqlClient::Tuple`) (defaults to: `nil`) —
  the prepared query arguments

Returns:

- (`::VertxSqlClient::RowStream`) —
  the createStream

Raises:

- (`ArgumentError`)

    69
    70
    71
    72
    73
    74
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 69

    def create_stream(fetch=nil,args=nil)
      if fetch.class == Fixnum && args.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createStream, [Java::int.java_class,Java::IoVertxSqlclient::Tuple.java_class]).call(fetch,args.j_del),::VertxSqlClient::RowStream,::VertxSqlClient::Row.j_api_type)
      end
      raise ArgumentError, "Invalid arguments when calling create_stream(#{fetch},#{args})"
    end

### - (`::VertxSqlClient::Cursor`) cursor(args = nil)

Create a cursor with the provided `arguments`.

Parameters:

- args (`::VertxSqlClient::Tuple`) (defaults to: `nil`) —
  the list of arguments

Returns:

- (`::VertxSqlClient::Cursor`) —
  the query

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    60
    61
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 54

    def cursor(args=nil)
      if !block_given? && args == nil
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cursor, []).call(),::VertxSqlClient::Cursor)
      elsif args.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cursor, [Java::IoVertxSqlclient::Tuple.java_class]).call(args.j_del),::VertxSqlClient::Cursor)
      end
      raise ArgumentError, "Invalid arguments when calling cursor(#{args})"
    end

### - (`self`) execute(args = nil) { ... }

Create a cursor with the provided `arguments`.

Parameters:

- args (`::VertxSqlClient::Tuple`) (defaults to: `nil`) —
  the list of arguments

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_query.rb', line 41

    def execute(args=nil)
      if block_given? && args == nil
        @j_del.java_method(:execute, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
        return self
      elsif args.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:execute, [Java::IoVertxSqlclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(args.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling execute(#{args})"
    end