1 package iotrmi.Java.sample;
5 import java.util.ArrayList;
7 public class TestClass implements TestClassInterface {
14 private String stringC;
15 private CallBackInterface cb;
16 private List<CallBackInterface> cblist;
27 cblist = new ArrayList<CallBackInterface>();
31 public TestClass(int _int, float _float, String _string) {
37 cblist = new ArrayList<CallBackInterface>();
41 public void setA(int _int) {
47 public void setB(float _float) {
53 public void setC(String _string) {
60 public String sumArray(String[] newA) {
69 public int setAndGetA(int newA) {
76 public int setACAndGetA(String newC, int newA) {
84 public void registerCallback(CallBackInterface _cb) {
90 public void registerCallback(CallBackInterface[] _cb) {
92 for (CallBackInterface cb : _cb) {
94 System.out.println("Registering callback object!");
99 //public int callBack() {
100 // return cb.printInt();
104 public int callBack() {
107 for (CallBackInterface cb : cblist) {
108 sum = sum + cb.printInt();
111 /*final CallBackInterface cb1 = cblist.get(1);
112 final CallBackInterface cb2 = cblist.get(2);
114 Thread thread1 = new Thread() {
117 for(int i = 0; i < 10; i++) {
121 } catch (Exception ex){
122 ex.printStackTrace();
123 throw new Error("Error running thread!");
129 Thread thread2 = new Thread() {
132 for(int i = 0; i < 10; i++) {
136 } catch (Exception ex){
137 ex.printStackTrace();
138 throw new Error("Error running thread!");
148 public void handleStruct(StructJ[] data) {
150 for (StructJ str : data) {
151 System.out.println("Name: " + str.name);
152 System.out.println("Value: " + str.value);
153 System.out.println("Year: " + str.year);
158 public void handleEnum(EnumJ[] en) {
161 System.out.println("Enum: " + e);
166 public static void main(String[] args) {
168 //TestClass tc = new TestClass();
169 //CallBack cb = new CallBack(3);
171 //tc.registerCallback(cb);
172 //System.out.println("Return value: " + tc.callBack());