Early version of RMI system for Java part; supports primitives, one-dimensional array...
[iot2.git] / iotjava / iotrmi / Java / sample / TestClass.java
1 package iotrmi.Java.sample;
2
3 import java.util.Set;
4
5 public class TestClass {
6
7         /**
8          * Class Properties
9          */
10         private int intA;
11         private float floatB;
12         private String stringC;
13         private CallBackInterface cb;
14
15         /**
16          * Constructors
17          */
18         public TestClass() {
19
20                 intA = 1;
21                 floatB = 2;
22                 stringC = "345";
23                 cb = null;
24         }
25
26
27         public TestClass(int _int, float _float, String _string) {
28
29                 intA = _int;
30                 floatB = _float;
31                 stringC = _string;
32         }
33
34
35         public void setA(int _int) {
36
37                 intA = _int;
38         }
39
40
41         public void setB(float _float) {
42
43                 floatB = _float;
44         }
45
46
47         public void setC(String _string) {
48
49                 stringC = _string;
50         }
51
52
53         // Getters
54         public String sumArray(String[] newA) {
55
56                 String sum = "";
57                 for (String i : newA) 
58                         sum = sum + i;
59                 return sum;
60         }
61
62
63         public int setAndGetA(int newA) {
64
65                 intA = newA;
66                 return intA;
67         }
68
69
70         public int setACAndGetA(String newC, int newA) {
71
72                 stringC = newC;
73                 intA = newA;
74                 return intA;
75         }
76
77
78         public void registerCallback(CallBackInterface _cb) {
79
80                 cb = _cb;
81         }
82
83
84         public int callBack() {
85
86                 System.out.println("This callBack function is called inside TestClass!");
87                 return cb.printInt();
88         }
89
90
91         public static void main(String[] args) {
92
93                 TestClass tc = new TestClass();
94                 CallBack cb = new CallBack(3);
95
96                 tc.registerCallback(cb);
97                 System.out.println("Return value: " + tc.callBack());
98         }
99 }