Preparing for callback testing (creating new policy files); Adding error messsages...
[iot2.git] / iotjava / iotrmi / Java / basics / TestClass.java
1 import java.util.Set;
2 import java.util.List;
3 import java.util.ArrayList;
4
5 public class TestClass implements TestClassInterface {
6
7         /**
8          * Class Properties
9          */
10         private int intA;
11         private float floatB;
12         private String stringC;
13         private List<CallBackInterface> cblist;
14
15         /**
16          * Constructors
17          */
18         public TestClass() {
19
20                 intA = 1;
21                 floatB = 2;
22                 stringC = "345";
23         }
24
25
26         public TestClass(int _int, float _float, String _string) {
27
28                 intA = _int;
29                 floatB = _float;
30                 stringC = _string;
31         }
32
33
34         // Callback
35         public void registerCallback(CallBackInterface _cb) {
36
37                 cblist.add(cb);
38                 System.out.println("Registering callback object!");
39         }
40
41
42         /*public void registerCallback(CallBackInterface[] _cb) {
43
44                 for (CallBackInterface cb : _cb) {
45                         cblist.add(cb);
46                         System.out.println("Registering callback object!");
47                 }
48         }*/
49
50
51         public int callBack() {
52
53                 int sum = 0;
54                 for (CallBackInterface cb : cblist) {
55                         sum = sum + cb.printInt();
56                 }
57                 return sum;
58         }
59
60
61         // Single variables
62         public byte getByte(byte in) {
63
64                 return in;
65         }
66
67
68         public short getShort(short in) {
69
70                 return in;
71         }
72
73
74         public long getLong(long in) {
75
76                 return in;
77         }
78
79
80         public float getFloat(float in) {
81
82                 return in;
83         }
84
85
86         public double getDouble(double in) {
87
88                 return in;
89         }
90
91
92         public boolean getBoolean(boolean in) {
93
94                 return in;
95         }
96
97
98         public char getChar(char in) {
99
100                 return in;
101         }
102
103
104         // Arrays
105         public byte[] getByteArray(byte[] in) {
106
107                 return in;
108         }
109
110
111         public short[] getShortArray(short[] in) {
112
113                 return in;
114         }
115
116
117         public long[] getLongArray(long[] in) {
118
119                 return in;
120         }
121
122
123         public float[] getFloatArray(float[] in) {
124
125                 return in;
126         }
127
128
129         public double[] getDoubleArray(double[] in) {
130
131                 return in;
132         }
133
134
135         public boolean[] getBooleanArray(boolean[] in) {
136
137                 return in;
138         }
139
140
141         public char[] getCharArray(char[] in) {
142
143                 return in;
144         }
145
146
147         // Lists
148         public List<Byte> getByteList(List<Byte> in) {
149
150                 return in;
151         }
152
153
154         public List<Short> getShortList(List<Short> in) {
155
156                 return in;
157         }
158
159
160         public List<Long> getLongList(List<Long> in) {
161
162                 return in;
163         }
164
165
166         public List<Float> getFloatList(List<Float> in) {
167
168                 return in;
169         }
170
171
172         public List<Double> getDoubleList(List<Double> in) {
173
174                 return in;
175         }
176
177
178         public List<Boolean> getBooleanList(List<Boolean> in) {
179
180                 return in;
181         }
182
183
184         public List<Character> getCharList(List<Character> in) {
185
186                 return in;
187         }
188
189
190         // Other functions
191         public int getA() {
192
193                 return intA;
194         }
195
196
197         public void setA(int _int) {
198
199                 intA = _int;
200         }
201
202
203         public void setB(float _float) {
204
205                 floatB = _float;
206         }
207
208
209         public void setC(String _string) {
210
211                 stringC = _string;
212         }
213
214
215         // Getters
216         public String sumArray(String[] newA) {
217
218                 String sum = "";
219                 for (String i : newA) 
220                         sum = sum + i;
221                 return sum;
222         }
223
224
225         public int setAndGetA(int newA) {
226
227                 intA = newA;
228                 return intA;
229         }
230
231
232         public int setACAndGetA(String newC, int newA) {
233
234                 stringC = newC;
235                 intA = newA;
236                 return intA;
237         }
238 }