Module: HelloJavaLib

Defined in:
lib/hellojava.rb

Class Method Summary collapse

Class Method Details

.func_avoid

Systemクラス使用

Examples:

HelloJavaLib::func_a()   => 'Hello, JRuby'


14
15
16
# File 'lib/hellojava.rb', line 14

def func_a()
    System.out.println("Hello, JRuby")
end

.func_bvoid

標準クラス以外の使用

Examples:

HelloJavaLib::func_b()   => 'str1'


23
24
25
26
# File 'lib/hellojava.rb', line 23

def func_b()
    p JavaCallTest.str1
    return
end

.func_c(value1, value2) ⇒ void

戻り値がオブジェクトの場合

Examples:

HelloJavaLib::func_c(1, 2)   => 3


35
36
37
38
39
40
# File 'lib/hellojava.rb', line 35

def func_c(value1, value2)
    hoge = Hoge.new
    calc = hoge.getCalc(value1, value2)
    p calc.add
    return
end

.func_d(fname, vals) ⇒ void

引数に二次元配列の場合

Examples:

vals = [
         [12.3, 22.5, 33.7, 44.6],
         [12.3, 22.5, 33.7, 44.6, 55.8],
       ]
HelloJavaLib::func_d("fname.jpg", vals) 
=>
 fname:fname.jpg size:2
 vals[0] size:4
 12.300000 22.500000 33.700000 44.600000
 vals[1] size:5
 12.300000 22.500000 33.700000 44.600000 55.800000


59
60
61
62
63
64
# File 'lib/hellojava.rb', line 59

def func_d(fname, vals)
    p JavaCallTest.sub1(
      fname, vals.to_java(Java::double[])
    );
    return
end