Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
require 'vertx-pg-client/pg_client'
require 'vertx-pg-client/tuple'
require 'vertx-pg-client/pg_transaction'
require 'vertx-pg-client/row'
require 'vertx-pg-client/pg_prepared_query'
require 'vertx-pg-client/pg_result'
require 'vertx/util/utils.rb'
# Generated from com.julienviet.pgclient.PgConnection
module VertxPgClient
# A connection to Postgres.
class PgConnection < ::VertxPgClient::PgClient
# @private
# @param j_del [::VertxPgClient::PgConnection] the java delegate
def initialize(j_del)
super(j_del)
@j_del = j_del
end
# @private
# @return [::VertxPgClient::PgConnection] the underlying java delegate
def j_del
@j_del
end
@@j_api_type = Object.new
def @@j_api_type.accept?(obj)
obj.class == PgConnection
end
def @@j_api_type.wrap(obj)
PgConnection.new(obj)
end
def @@j_api_type.unwrap(obj)
obj.j_del
end
def self.j_api_type
@@j_api_type
end
def self.j_class
Java::ComJulienvietPgclient::PgConnection.java_class
end
# Create a prepared query.
# @param [String] sql the sql
# @yield the handler notified with the prepared query asynchronously
# @return [self]
def prepare(sql=nil)
if sql.class == String && block_given?
@j_del.java_method(:prepare, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgPreparedQuery) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling prepare(#{sql})"
end
# Set an handler called with connection errors.
# @yield the handler
# @return [self]
def exception_handler
if block_given?
@j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
return self
end
raise ArgumentError, "Invalid arguments when calling exception_handler()"
end
# Set an handler called when the connection is closed.
# @yield the handler
# @return [self]
def close_handler
if block_given?
@j_del.java_method(:closeHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
return self
end
raise ArgumentError, "Invalid arguments when calling close_handler()"
end
# Begin a transaction and returns a {::VertxPgClient::PgTransaction} for controlling and tracking
# this transaction.
#
# When the connection is explicitely closed, any inflight transaction is rollbacked.
# @return [::VertxPgClient::PgTransaction] the transaction instance
def begin
if !block_given?
return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:begin, []).call(),::VertxPgClient::PgTransaction)
end
raise ArgumentError, "Invalid arguments when calling begin()"
end
# Set an handler called when the connection receives notification on a channel.
#
# The handler is called with the {Hash} and has access to the channel name
# and the notification payload.
# @yield the handler
# @return [self]
def notification_handler
if block_given?
@j_del.java_method(:notificationHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling notification_handler()"
end
# @return [true,false] whether the connection uses SSL
def ssl?
if !block_given?
return @j_del.java_method(:isSSL, []).call()
end
raise ArgumentError, "Invalid arguments when calling ssl?()"
end
# Close the current connection after all the pending commands have been processed.
# @return [void]
def close
if !block_given?
return @j_del.java_method(:close, []).call()
end
raise ArgumentError, "Invalid arguments when calling close()"
end
# @param [String] sql
# @param [::VertxPgClient::Tuple] arguments
# @yield
# @return [self]
def prepared_query(sql=nil,arguments=nil)
if sql.class == String && block_given? && arguments == nil
@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
elsif sql.class == String && arguments.class.method_defined?(:j_del) && block_given?
@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::ComJulienvietPgclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,arguments.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql},#{arguments})"
end
# @param [String] sql
# @yield
# @return [self]
def query(sql=nil)
if sql.class == String && block_given?
@j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end
# @param [String] sql
# @param [Array<::VertxPgClient::Tuple>] batch
# @yield
# @return [self]
def prepared_batch(sql=nil,batch=nil)
if sql.class == String && batch.class == Array && block_given?
@j_del.java_method(:preparedBatch, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,batch.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling prepared_batch(#{sql},#{batch})"
end
end
end