3 import java.util.ArrayList;
4 import java.util.Arrays;
6 public class TestClass implements TestClassInterface {
13 private String stringC;
14 private List<CallBackInterfaceWithCallBack> cblist;
24 cblist = new ArrayList<CallBackInterfaceWithCallBack>();
28 public TestClass(int _int, float _float, String _string) {
33 cblist = new ArrayList<CallBackInterfaceWithCallBack>();
37 public int callBack() {
40 System.out.println("Callback called! cblist: " + cblist.size());
41 for (CallBackInterfaceWithCallBack cb : cblist) {
42 sum = sum + cb.printInt();
43 //TestClass tci = new TestClass();
44 cb.needCallback(this);
45 //cb.needCallback(this);
46 //cb.needCallback(tci);
47 System.out.println("Inside the loop!");
49 System.out.println("Executed callback of callback! Returning value: " + sum + "\n\n");
54 //public void registerCallback(CallBackInterface _cb) {
55 public void registerCallback(CallBackInterfaceWithCallBack _cb) {
58 System.out.println("Registering callback object! Items: " + cblist.size());
62 public void registerCallbackArray(CallBackInterfaceWithCallBack _cb[]) {
64 for (CallBackInterfaceWithCallBack cb : _cb) {
66 System.out.println("Registering callback objects in array!");
71 public void registerCallbackList(List<CallBackInterfaceWithCallBack> _cb) {
73 for (CallBackInterfaceWithCallBack cb : _cb) {
75 System.out.println("Registering callback objects in list!");
80 public void registerCallbackComplex(int in, List<CallBackInterfaceWithCallBack> _cb, double db) {
82 for (CallBackInterfaceWithCallBack cb : _cb) {
84 System.out.println("Registering callback objects in list!");
87 System.out.println("Integer: " + in);
88 System.out.println("Double: " + db);
93 public byte getByte(byte in) {
99 public short getShort(short in) {
105 public long getLong(long in) {
111 public float getFloat(float in) {
117 public double getDouble(double in) {
123 public boolean getBoolean(boolean in) {
129 public char getChar(char in) {
136 public byte[] getByteArray(byte[] in) {
142 public short[] getShortArray(short[] in) {
148 public long[] getLongArray(long[] in) {
154 public float[] getFloatArray(float[] in) {
160 public double[] getDoubleArray(double[] in) {
166 public boolean[] getBooleanArray(boolean[] in) {
172 public char[] getCharArray(char[] in) {
179 public List<Byte> getByteList(List<Byte> in) {
185 public List<Short> getShortList(List<Short> in) {
191 public List<Long> getLongList(List<Long> in) {
197 public List<Float> getFloatList(List<Float> in) {
203 public List<Double> getDoubleList(List<Double> in) {
209 public List<Boolean> getBooleanList(List<Boolean> in) {
215 public List<Character> getCharList(List<Character> in) {
228 public void setA(int _int) {
234 public void setB(float _float) {
240 public void setC(String _string) {
247 public Enum handleEnum(Enum en) {
249 System.out.println("Enum: " + en);
255 public Enum[] handleEnumArray(Enum[] en) {
258 System.out.println("Enum: " + e);
265 public List<Enum> handleEnumList(List<Enum> en) {
268 System.out.println("Enum: " + e);
275 public Enum handleEnumComplex(Enum en, int i, char c) {
277 System.out.println("Enum: " + en);
278 System.out.println("Integer: " + i);
279 System.out.println("Char: " + c);
285 public Enum[] handleEnumComplex2(Enum[] en, int in, char c) {
288 System.out.println("Enum: " + e);
290 System.out.println("Integer: " + in);
291 System.out.println("Char: " + c);
297 public Enum[] handleEnumTwo(Enum en1[], Enum en2[]) {
300 System.out.println("Enum1: " + e);
303 System.out.println("Enum2: " + e);
310 public Enum[] handleEnumThree(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2) {
313 System.out.println("Enum1: " + e);
316 System.out.println("Enum2: " + e);
324 public Struct handleStruct(Struct str) {
326 System.out.println("Name: " + str.name);
327 System.out.println("Value: " + str.value);
328 System.out.println("Year: " + str.year);
331 Struct test = new Struct();
332 test.name = "Anonymous";
342 public Struct[] handleStructArray(Struct str[]) {
344 for (Struct st : str) {
345 System.out.println("Name: " + st.name);
346 System.out.println("Value: " + st.value);
347 System.out.println("Year: " + st.year);
350 Struct test = new Struct();
351 test.name = "Anonymous";
361 public List<Struct> handleStructList(List<Struct> str) {
363 for (Struct st : str) {
364 System.out.println("Name: " + st.name);
365 System.out.println("Value: " + st.value);
366 System.out.println("Year: " + st.year);
369 Struct test = new Struct();
380 public Struct handleStructComplex(int in, char c, Struct str) {
382 System.out.println("Name: " + str.name);
383 System.out.println("Value: " + str.value);
384 System.out.println("Year: " + str.year);
386 System.out.println("Integer: " + in);
387 System.out.println("Char: " + c);
389 Struct test = new Struct();
390 test.name = "Anonymous";
400 public List<Struct> handleStructComplex2(int in, char c, Struct str[]) {
402 for (Struct st : str) {
403 System.out.println("Name: " + st.name);
404 System.out.println("Value: " + st.value);
405 System.out.println("Year: " + st.year);
408 System.out.println("Integer: " + in);
409 System.out.println("Char: " + c);
411 return new ArrayList<Struct>(Arrays.asList(str));
415 public Enum[] handleEnumStruct(Enum en[], List<Struct> str, char c) {
417 for (Struct st : str) {
418 System.out.println("Name: " + st.name);
419 System.out.println("Value: " + st.value);
420 System.out.println("Year: " + st.year);
423 System.out.println("Char: " + c);
429 public List<Struct> handleStructTwo(List<Struct> str1, List<Struct> str2) {
431 for (Struct st : str1) {
432 System.out.println("Name: " + st.name);
433 System.out.println("Value: " + st.value);
434 System.out.println("Year: " + st.year);
441 public List<Struct> handleStructThree(List<Struct> str1, List<Struct> str2, List<Struct> str3) {
443 for (Struct st : str1) {
444 System.out.println("Name: " + st.name);
445 System.out.println("Value: " + st.value);
446 System.out.println("Year: " + st.year);
453 public Enum[] handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterfaceWithCallBack> _cb) {
455 for (CallBackInterfaceWithCallBack cb : _cb) {
457 System.out.println("Registering callback objects in list!");
460 for (Struct st : str) {
461 System.out.println("Name: " + st.name);
462 System.out.println("Value: " + st.value);
463 System.out.println("Year: " + st.year);
466 System.out.println("Char: " + c);
472 public Enum[] handleCallbackEnum(Enum en[], char c, List<CallBackInterfaceWithCallBack> _cb) {
474 for (CallBackInterfaceWithCallBack cb : _cb) {
476 System.out.println("Registering callback objects in list!");
479 System.out.println("Char: " + c);
485 public Enum[] handleAllTwo(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2, char c, List<CallBackInterfaceWithCallBack> _cb1, List<CallBackInterfaceWithCallBack> _cb2) {
487 for (CallBackInterfaceWithCallBack cb : _cb1) {
489 System.out.println("Registering callback objects in list!");
492 for (Struct st : str1) {
493 System.out.println("Name: " + st.name);
494 System.out.println("Value: " + st.value);
495 System.out.println("Year: " + st.year);
498 System.out.println("Char: " + c);
505 public String sumArray(String[] newA) {
508 for (String i : newA)
514 public int setAndGetA(int newA) {
521 public int setACAndGetA(String newC, int newA) {
528 public static void main(String[] args) {
530 TestClass tc = new TestClass();
531 System.out.println("Get short: " + tc.getShort((short) 1234));