Class: Handle::Java::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/handle/java/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(handle, index, *auth) ⇒ Connection

A more Ruby-ish HSAdapter



6
7
8
9
10
11
12
13
14
15
# File 'lib/handle/java/connection.rb', line 6

def initialize(handle, index, *auth)
  # accept either a key file or the key itself
  if auth.length == 2 and (not auth[0].bytes.to_a.include?(0)) and File.exists?(auth[0])
    auth[0] = File.read(auth[0])
  end
  auth_params = auth.collect { |p| p.to_java_bytes }
  protect {
    @conn = Native::HSAdapterFactory.new_instance(handle, index, *auth_params)
  }
end

Instance Method Details

#add_handle_values(handle, record) ⇒ Object



17
18
19
20
21
# File 'lib/handle/java/connection.rb', line 17

def add_handle_values(handle, record)
  protect {
    @conn.addHandleValues(handle, record.to_java)
  }
end

#create_handle(handle, record) ⇒ Object



23
24
25
26
27
# File 'lib/handle/java/connection.rb', line 23

def create_handle(handle, record)
  protect {
    @conn.createHandle(handle, record.to_java)
  }
end

#create_record(handle) ⇒ Object



29
30
31
32
33
34
# File 'lib/handle/java/connection.rb', line 29

def create_record(handle)
  result = Handle::Record.new
  result.connection = self
  result.handle = handle
  result
end

#delete_handle(handle) ⇒ Object



36
37
38
39
40
# File 'lib/handle/java/connection.rb', line 36

def delete_handle(handle)
  protect {
    @conn.deleteHandle(handle)
  }
end

#delete_handle_values(handle, record) ⇒ Object



42
43
44
45
46
# File 'lib/handle/java/connection.rb', line 42

def delete_handle_values(handle, record)
  protect {
    @conn.deleteHandleValues(handle, record.to_java)
  }
end

#nativeObject



73
74
75
# File 'lib/handle/java/connection.rb', line 73

def native
  @conn
end

#resolve_handle(handle, types = [], indexes = [], auth = true) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/handle/java/connection.rb', line 48

def resolve_handle(handle, types=[], indexes=[], auth=true)
  protect {
    java_response = @conn.resolveHandle(
      handle, types.to_java(:string), 
      indexes.to_java(:int), auth
    )
    result = Handle::Record.from_data(java_response)
    result.connection = self
    result.handle = handle
    result
  }
end

#update_handle_values(handle, record) ⇒ Object



67
68
69
70
71
# File 'lib/handle/java/connection.rb', line 67

def update_handle_values(handle, record)
  protect {
    @conn.updateHandleValues(handle, record.to_java)
  }
end

#use_udp=(value) ⇒ Object



61
62
63
64
65
# File 'lib/handle/java/connection.rb', line 61

def use_udp=(value)
  protect {
    @conn.setUseUDP(value)
  }
end