1 | import javax.swing.JApplet;
|
---|
2 | import java.awt.Graphics;
|
---|
3 | import java.awt.*;
|
---|
4 | import java.applet.*;
|
---|
5 | import java.awt.event.*;
|
---|
6 | import netscape.javascript.JSObject;
|
---|
7 | import java.lang.reflect.Array;
|
---|
8 |
|
---|
9 | public class PluginTest extends JApplet {
|
---|
10 |
|
---|
11 | public int i = 42;
|
---|
12 | public double d = 42.42;
|
---|
13 | public float f = 42.1F;
|
---|
14 | public long l = 4294967296L;
|
---|
15 | public boolean b = true;
|
---|
16 | public char c = '\u2323';
|
---|
17 | public byte by = 43;
|
---|
18 | public String rs = "I'm a string!";
|
---|
19 | public String ss = "ð ã£$Ç£â¬ð";
|
---|
20 | public Object n = null;
|
---|
21 | public int[] ia = new int[5];
|
---|
22 |
|
---|
23 | public Integer I = 24;
|
---|
24 | public Double D = 24.24;
|
---|
25 | public Float F = 24.124F;
|
---|
26 | public Long L = 6927694924L;
|
---|
27 | public Boolean B = false;
|
---|
28 | public Character C = '\u1526';
|
---|
29 | public Byte By = 34;
|
---|
30 | public Double[] Da1 = new Double[10];
|
---|
31 | public Double[] Da2 = null;
|
---|
32 |
|
---|
33 | public char[] ca = new char[3];
|
---|
34 | public Character[] Ca = new Character[3];
|
---|
35 |
|
---|
36 | public void setUpForGMTests() {
|
---|
37 | i = 42;
|
---|
38 | d = 42.42;
|
---|
39 | f = 42.1F;
|
---|
40 | l = 4294967296L;
|
---|
41 | b = true;
|
---|
42 | c = '\u2323';
|
---|
43 | by = 43;
|
---|
44 | rs = "I'm a string!";
|
---|
45 | ss = "ð ã£$Ç£â¬ð";
|
---|
46 | n = null;
|
---|
47 |
|
---|
48 | I = 24;
|
---|
49 | D = 24.24;
|
---|
50 | F = 24.124F;
|
---|
51 | L = 6927694924L;
|
---|
52 | B = false;
|
---|
53 | C = '\u1526';
|
---|
54 | By = 34;
|
---|
55 |
|
---|
56 | ia[4] = 1024;
|
---|
57 | Da1[9] = D;
|
---|
58 | }
|
---|
59 |
|
---|
60 | public void setUpForSMTests() {
|
---|
61 | i = 0;
|
---|
62 | d = 0.0;
|
---|
63 | f = 0F;
|
---|
64 | l = 0L;
|
---|
65 | b = false;
|
---|
66 | c = 'A';
|
---|
67 | by = 0;
|
---|
68 | rs = "";
|
---|
69 | ss = "";
|
---|
70 | n = new String("non-null object");
|
---|
71 |
|
---|
72 | I = 0;
|
---|
73 | D = 0.0;
|
---|
74 | F = 0F;
|
---|
75 | L = 0L;
|
---|
76 | B = false;
|
---|
77 | C = 'A';
|
---|
78 | By = null;
|
---|
79 |
|
---|
80 | ia[4] = 0;
|
---|
81 | Da1[9] = D;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /*
|
---|
85 | *****************************************
|
---|
86 | * JS -> Java Parameter conversion tests *
|
---|
87 | *****************************************
|
---|
88 | */
|
---|
89 | public void setUpForReturnTests() {
|
---|
90 | i = 41;
|
---|
91 | d = 41.41;
|
---|
92 | f = 41.411F;
|
---|
93 | l = 4294967297L;
|
---|
94 | b = true;
|
---|
95 | c = '\u2329';
|
---|
96 | by = 44;
|
---|
97 | rs = "I'm a string too!";
|
---|
98 | ss = "ð ã£$Ç£â¬ð";
|
---|
99 | n = null;
|
---|
100 |
|
---|
101 | I = 14;
|
---|
102 | D = 14.14;
|
---|
103 | F = 14.114F;
|
---|
104 | L = 6927694925L;
|
---|
105 | B = false;
|
---|
106 | C = '\u2417';
|
---|
107 | By = 46;
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | **************************************
|
---|
112 | * JS -> Java invocation return tests *
|
---|
113 | **************************************
|
---|
114 | */
|
---|
115 |
|
---|
116 | public int intReturnTest() { return i; }
|
---|
117 |
|
---|
118 | public double doubleReturnTest() { return d; }
|
---|
119 |
|
---|
120 | public float floatReturnTest() { return f; }
|
---|
121 |
|
---|
122 | public long longReturnTest() { return l; }
|
---|
123 |
|
---|
124 | public boolean booleanReturnTest() { return b; }
|
---|
125 |
|
---|
126 | public char charReturnTest() { return c; }
|
---|
127 |
|
---|
128 | public byte byteReturnTest() { return by; }
|
---|
129 |
|
---|
130 | public char[] charArrayReturnTest() {
|
---|
131 | ca[0] = '\u2410';
|
---|
132 | ca[1] = '\u2411';
|
---|
133 | ca[2] = '\u2412';
|
---|
134 | return ca;
|
---|
135 | }
|
---|
136 |
|
---|
137 | public String regularStringReturnTest() { return rs; }
|
---|
138 |
|
---|
139 | public String specialStringReturnTest() { return ss; }
|
---|
140 |
|
---|
141 | public void voidReturnTest() { }
|
---|
142 |
|
---|
143 | public Object nullReturnTest() { return null; }
|
---|
144 |
|
---|
145 | public Integer IntegerReturnTest() { return I; }
|
---|
146 |
|
---|
147 | public Double DoubleReturnTest() { return D; }
|
---|
148 | public void DoubleSetTest(double set) { D = set; }
|
---|
149 |
|
---|
150 | public Float FloatReturnTest() { return F; }
|
---|
151 |
|
---|
152 | public Long LongReturnTest() { return L; }
|
---|
153 |
|
---|
154 | public Boolean BooleanReturnTest() { return B; }
|
---|
155 |
|
---|
156 | public Character CharacterReturnTest() { return C; }
|
---|
157 |
|
---|
158 | public Byte ByteReturnTest() { return By; }
|
---|
159 |
|
---|
160 | public Character[] CharacterArrayReturnTest() {
|
---|
161 | Ca[0] = '\u2350';
|
---|
162 | Ca[1] = '\u2351';
|
---|
163 | Ca[2] = '\u2352';
|
---|
164 | return Ca;
|
---|
165 | }
|
---|
166 |
|
---|
167 | /*
|
---|
168 | **************************************
|
---|
169 | * JS -> Java parameter passing tests *
|
---|
170 | **************************************
|
---|
171 | */
|
---|
172 |
|
---|
173 | public void setUpForParameterTests() {
|
---|
174 | i = 41;
|
---|
175 | d = 41.41;
|
---|
176 | f = 41.411F;
|
---|
177 | l = 4294967297L;
|
---|
178 | b = true;
|
---|
179 | c = '\u2329';
|
---|
180 | by = 44;
|
---|
181 | rs = "I'm a string too!";
|
---|
182 | ss = "ð ã£$Ç£â¬ð";
|
---|
183 | n = null;
|
---|
184 |
|
---|
185 | I = 14;
|
---|
186 | D = 14.14;
|
---|
187 | F = 14.114F;
|
---|
188 | L = 6927694925L;
|
---|
189 | B = false;
|
---|
190 | C = '\u2417';
|
---|
191 | By = 46;
|
---|
192 | }
|
---|
193 |
|
---|
194 | public String functioniParamTest(int i) {
|
---|
195 | String ret = Integer.toString(i);
|
---|
196 | return ret;
|
---|
197 | }
|
---|
198 |
|
---|
199 | public String functiondParamTest(double d) {
|
---|
200 | String ret = Double.toString(d);
|
---|
201 | return ret;
|
---|
202 | }
|
---|
203 |
|
---|
204 | public String functionfParamTest(float f) {
|
---|
205 | String ret = Float.toString(f);
|
---|
206 | return ret;
|
---|
207 | }
|
---|
208 |
|
---|
209 | public String functionlParamTest(long l) {
|
---|
210 | String ret = Long.toString(l);
|
---|
211 | return ret;
|
---|
212 | }
|
---|
213 |
|
---|
214 | public String functionbParamTest(boolean b) {
|
---|
215 | String ret = Boolean.toString(b);
|
---|
216 | return ret;
|
---|
217 | }
|
---|
218 |
|
---|
219 | public String functioncParamTest(char c) {
|
---|
220 | String ret = Character.toString(c);
|
---|
221 | return ret;
|
---|
222 | }
|
---|
223 |
|
---|
224 | public String functionbyParamTest(byte b) {
|
---|
225 | String ret = Byte.toString(b);
|
---|
226 | return ret;
|
---|
227 | }
|
---|
228 |
|
---|
229 | public String functioncaParamTest(char[] ca) {
|
---|
230 |
|
---|
231 | String ret = "";
|
---|
232 | ret += ca[0];
|
---|
233 | for (int i=1 ; i < ca.length; i++) {
|
---|
234 | ret += ":" + ca[i];
|
---|
235 | }
|
---|
236 |
|
---|
237 | return ret;
|
---|
238 | }
|
---|
239 |
|
---|
240 | public String functionsiaParamTest(String[] s) {
|
---|
241 |
|
---|
242 | String ret = s[0];
|
---|
243 | for (int i=1 ; i < s.length; i++) {
|
---|
244 | ret += ":" + s[i];
|
---|
245 | }
|
---|
246 |
|
---|
247 | return ret;
|
---|
248 | }
|
---|
249 |
|
---|
250 | public String functionsParamTest(String s) {
|
---|
251 | return s + ":" + s.getClass().getName();
|
---|
252 | }
|
---|
253 |
|
---|
254 | public String functionIParamTest(Integer p) {
|
---|
255 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
256 | return ret;
|
---|
257 | }
|
---|
258 |
|
---|
259 | public String functionDParamTest(Double p) {
|
---|
260 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
261 | return ret;
|
---|
262 | }
|
---|
263 |
|
---|
264 | public String functionFParamTest(Float p) {
|
---|
265 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
266 | return ret;
|
---|
267 | }
|
---|
268 |
|
---|
269 | public String functionLParamTest(Long p) {
|
---|
270 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
271 | return ret;
|
---|
272 | }
|
---|
273 |
|
---|
274 | public String functionBParamTest(Boolean p) {
|
---|
275 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
276 | return ret;
|
---|
277 | }
|
---|
278 |
|
---|
279 | public String functionCParamTest(Character p) {
|
---|
280 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
281 | return ret;
|
---|
282 | }
|
---|
283 |
|
---|
284 | public String functionBParamTest(Byte p) {
|
---|
285 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
286 | return ret;
|
---|
287 | }
|
---|
288 |
|
---|
289 | public String functionCaParamTest(Character p) {
|
---|
290 | String ret = p.toString() + ":" + p.getClass().getName();
|
---|
291 | return ret;
|
---|
292 | }
|
---|
293 |
|
---|
294 | public String functioncomplexaParamTest(DummyObject[] ca) {
|
---|
295 | String ret = ca[0].toString();
|
---|
296 | for (int i=1 ; i < ca.length; i++) {
|
---|
297 | ret += ":" + ca[i].toString();
|
---|
298 | }
|
---|
299 |
|
---|
300 | return ret;
|
---|
301 | }
|
---|
302 |
|
---|
303 | /*
|
---|
304 | ***********************************************
|
---|
305 | * JS -> Java overload resolution plugin tests *
|
---|
306 | ***********************************************
|
---|
307 | */
|
---|
308 |
|
---|
309 | /* Numeric type to the analogous Java primitive type */
|
---|
310 |
|
---|
311 | public String foo_num_to_num(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
|
---|
312 |
|
---|
313 | // int -> int is lower than:
|
---|
314 | // int to double
|
---|
315 | public String foo_num_to_num(long p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":long"; }
|
---|
316 | // int to String
|
---|
317 | public String foo_num_to_num(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
318 |
|
---|
319 |
|
---|
320 | /* Null to any non-primitive type */
|
---|
321 | public String foo_null_to_nonprim(Integer p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":Integer"; }
|
---|
322 |
|
---|
323 | // Null to non-prim is better than:
|
---|
324 | // null -> prim (not allowed)
|
---|
325 | public String foo_null_to_nonprim(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
|
---|
326 |
|
---|
327 |
|
---|
328 | /* JSObject to JSObject */
|
---|
329 | public String foo_jso_to_jso(JSObject p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":JSObject"; }
|
---|
330 |
|
---|
331 | // JSO -> JSO is better than:
|
---|
332 | // JSO -> String
|
---|
333 | public String foo_jso_to_jso(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
334 | // JSO -> Java array
|
---|
335 | public String foo_jso_to_jso(String[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
336 | // JSO -> Superclass (Object)
|
---|
337 | public String foo_jso_to_jso(Object p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
338 |
|
---|
339 |
|
---|
340 | /* Class type to Class type where the types are equal */
|
---|
341 | public String foo_ct_to_ct(OverloadTestHelper2 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
342 |
|
---|
343 | // CT -> CT is better than:
|
---|
344 | // CT -> Superclass
|
---|
345 | public String foo_ct_to_ct(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
346 | // CT->Subclass
|
---|
347 | public String foo_ct_to_ct(OverloadTestHelper3 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
348 |
|
---|
349 |
|
---|
350 |
|
---|
351 | /* Numeric type to a different primitive type */
|
---|
352 | public String foo_multiprim(double p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":double"; }
|
---|
353 |
|
---|
354 | // Num -> Diff. prim. is better than:
|
---|
355 | // Better than anything else.. using string as a dummy
|
---|
356 | public String foo_multiprim(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
357 |
|
---|
358 |
|
---|
359 |
|
---|
360 | /* String to numeric */
|
---|
361 | public String foo_strnum(double p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":double"; }
|
---|
362 |
|
---|
363 | // Str -> Num is better than:
|
---|
364 | // Anything else .. using OverloadTestHelper1 as a dummy
|
---|
365 | public String foo_strnum(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
366 |
|
---|
367 |
|
---|
368 | /* Class type to superclass type (with subclass passed) */
|
---|
369 | public String foo_ct_to_sc(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":OverloadTestHelper1"; }
|
---|
370 |
|
---|
371 | // CT -> Superclass is better than CT to String
|
---|
372 | public String foo_ct_to_sc(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
373 |
|
---|
374 |
|
---|
375 |
|
---|
376 | /* Any Java value to String */
|
---|
377 | public String foo_jv_to_str(String p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
378 |
|
---|
379 | // JV -> Str is better than anything else allowed
|
---|
380 | public String foo_jv_to_str(JSObject p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
381 |
|
---|
382 |
|
---|
383 |
|
---|
384 | /* JSO to Array (lower cost) */
|
---|
385 | public String foo_jso_to_array(int[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int[]"; }
|
---|
386 |
|
---|
387 | // JSO to array is better than:
|
---|
388 | // something not possible
|
---|
389 | public String foo_jso_to_array(Integer p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
390 |
|
---|
391 |
|
---|
392 | /****** Not allowed resolutions *******/
|
---|
393 |
|
---|
394 | /* null to primitive */
|
---|
395 | public String foo_null_to_prim(int p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":int"; }
|
---|
396 |
|
---|
397 | /* JSObject to something else */
|
---|
398 | public String foo_jso_to_somethingelse(OverloadTestHelper1 p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
399 |
|
---|
400 | /* Any other conversion not described ... e.g. sending non-array to array */
|
---|
401 | public String foo_unsupported(Object[] p) { return (new Throwable()).getStackTrace()[0].getMethodName() + ":" + p.getClass().getName(); }
|
---|
402 |
|
---|
403 | /*
|
---|
404 | ******************************
|
---|
405 | * JS -> Java type conversion *
|
---|
406 | ******************************
|
---|
407 | */
|
---|
408 |
|
---|
409 | public byte byte_type = 0;
|
---|
410 | public char char_type = 'A';
|
---|
411 | public short short_type = 0;
|
---|
412 | public int int_type = 0;
|
---|
413 | public long long_type = 0L;
|
---|
414 | public float float_type = 0F;
|
---|
415 | public double double_type = 0.0;
|
---|
416 | public boolean boolean_type = false;
|
---|
417 |
|
---|
418 | public byte[] byte_array = null;
|
---|
419 | public char[] char_array = null;
|
---|
420 | public short[] short_array = null;
|
---|
421 | public int[] int_array = null;
|
---|
422 | public long[] long_array = null;
|
---|
423 | public float[] float_array = null;
|
---|
424 | public double[] double_array = null;
|
---|
425 | public char[][] char_array_array = null;
|
---|
426 |
|
---|
427 | public Byte Byte_type = null;
|
---|
428 | public Character Character_type = 'A';
|
---|
429 | public Short Short_type = 0;
|
---|
430 | public Integer Integer_type = 0;
|
---|
431 | public Long Long_type = 0L;
|
---|
432 | public Float Float_type = 0F;
|
---|
433 | public Double Double_type = 0.0;
|
---|
434 | public String String_type = "";
|
---|
435 | public Boolean Boolean_type = false;
|
---|
436 | public JSObject JSObject_type = null;
|
---|
437 |
|
---|
438 | public Byte[] Byte_array = null;
|
---|
439 | public Character[] Character_array = null;
|
---|
440 | public Short[] Short_array = null;
|
---|
441 | public Integer[] Integer_array = null;
|
---|
442 | public Long[] Long_array = null;
|
---|
443 | public Float[] Float_array = null;
|
---|
444 | public Double[] Double_array = null;
|
---|
445 | public String[] String_array = null;
|
---|
446 | public String[][] String_array_array = null;
|
---|
447 |
|
---|
448 | public Object Object_type = null;
|
---|
449 |
|
---|
450 | public String getArrayAsStr(Object array) {
|
---|
451 | int size = Array.getLength(array);
|
---|
452 |
|
---|
453 | String ret = "";
|
---|
454 | for (int i=0; i < size; i++) {
|
---|
455 | ret += Array.get(array, i) == null ? "null" : Array.get(array, i).toString();
|
---|
456 | ret += ",";
|
---|
457 | }
|
---|
458 |
|
---|
459 | if (ret.length() > 0) {
|
---|
460 | ret = ret.substring(0, ret.length()-1);
|
---|
461 | }
|
---|
462 |
|
---|
463 | return ret;
|
---|
464 | }
|
---|
465 |
|
---|
466 | /*
|
---|
467 | **************************
|
---|
468 | **************************
|
---|
469 | * Begin Java -> JS tests *
|
---|
470 | **************************
|
---|
471 | **************************
|
---|
472 | */
|
---|
473 |
|
---|
474 | public DummyObject dummyObject = new DummyObject("DummyObject1");
|
---|
475 | public Object value;
|
---|
476 | private JSObject window;
|
---|
477 |
|
---|
478 | /*
|
---|
479 | *************************
|
---|
480 | * Java -> JS read tests *
|
---|
481 | *************************
|
---|
482 | */
|
---|
483 |
|
---|
484 | public boolean jjsReadIntTest() {
|
---|
485 | value = new Integer(window.getMember("intvar").toString());
|
---|
486 | return ((Integer) value).equals(1);
|
---|
487 | }
|
---|
488 |
|
---|
489 | public boolean jjsReadDoubleTest() {
|
---|
490 | value = new Double(window.getMember("doublevar").toString());
|
---|
491 | return ((Double) value).equals(1.1);
|
---|
492 | }
|
---|
493 |
|
---|
494 | public boolean jjsReadBooleanTest() {
|
---|
495 | value = new Boolean(window.getMember("boolvar").toString());
|
---|
496 | return ((Boolean) value).equals(true);
|
---|
497 | }
|
---|
498 |
|
---|
499 | public boolean jjsReadStringTest() {
|
---|
500 | value = window.getMember("stringvar").toString();
|
---|
501 | return ((String) value).equals("stringvar");
|
---|
502 | }
|
---|
503 |
|
---|
504 | public boolean jjsReadObjectTest() {
|
---|
505 | value = window.getMember("objectvar").toString();
|
---|
506 | return value.equals("DummyObject1");
|
---|
507 | }
|
---|
508 |
|
---|
509 | public boolean jjsRead1DArrayTest() {
|
---|
510 | value = ((JSObject) window.getMember("arrayvar")).getSlot(1);
|
---|
511 | return value.toString().equals("100");
|
---|
512 | }
|
---|
513 |
|
---|
514 | public boolean jjsRead2DArrayTest() {
|
---|
515 | value = ((JSObject) ((JSObject) window.getMember("arrayvar2")).getSlot(1)).getSlot(2);
|
---|
516 | return value.toString().equals("200");
|
---|
517 | }
|
---|
518 |
|
---|
519 | /*
|
---|
520 | **************************
|
---|
521 | * Java -> JS write tests *
|
---|
522 | **************************
|
---|
523 | */
|
---|
524 |
|
---|
525 | public void jjsSetIntTest() {
|
---|
526 | window.setMember("setvar", (int) 1);
|
---|
527 | }
|
---|
528 |
|
---|
529 | public void jjsSetIntegerTest() {
|
---|
530 | window.setMember("setvar", new Integer(2));
|
---|
531 | }
|
---|
532 |
|
---|
533 | public void jjsSetdoubleTest() {
|
---|
534 | window.setMember("setvar", (double) 2.1);
|
---|
535 | }
|
---|
536 |
|
---|
537 | public void jjsSetDoubleTest() {
|
---|
538 | window.setMember("setvar", new Double(2.2));
|
---|
539 | }
|
---|
540 |
|
---|
541 | public void jjsSetfloatTest() {
|
---|
542 | window.setMember("setvar", (float) 2.3);
|
---|
543 | }
|
---|
544 |
|
---|
545 | public void jjsSetFloatTest() {
|
---|
546 | window.setMember("setvar", new Float(2.4));
|
---|
547 | }
|
---|
548 |
|
---|
549 | public void jjsSetshortTest() {
|
---|
550 | window.setMember("setvar", (short) 3);
|
---|
551 | }
|
---|
552 |
|
---|
553 | public void jjsSetShortTest() {
|
---|
554 | window.setMember("setvar", new Short((short) 4));
|
---|
555 | }
|
---|
556 |
|
---|
557 | public void jjsSetlongTest() {
|
---|
558 | window.setMember("setvar", (long) 4294967296L);
|
---|
559 | }
|
---|
560 |
|
---|
561 | public void jjsSetLongTest() {
|
---|
562 | window.setMember("setvar", new Long(4294967297L));
|
---|
563 | }
|
---|
564 |
|
---|
565 | public void jjsSetbyteTest() {
|
---|
566 | window.setMember("setvar", (byte) 5);
|
---|
567 | }
|
---|
568 |
|
---|
569 | public void jjsSetByteTest() {
|
---|
570 | window.setMember("setvar", new Byte((byte) 6));
|
---|
571 | }
|
---|
572 |
|
---|
573 | public void jjsSetcharTest() {
|
---|
574 | window.setMember("setvar", (char) '\u2323');
|
---|
575 | }
|
---|
576 |
|
---|
577 | public void jjsSetCharacterTest() {
|
---|
578 | window.setMember("setvar", new Character('\u2324'));
|
---|
579 | }
|
---|
580 |
|
---|
581 | public void jjsSetbooleanTest() {
|
---|
582 | window.setMember("setvar", (boolean) true);
|
---|
583 | }
|
---|
584 |
|
---|
585 | public void jjsSetBooleanTest() {
|
---|
586 | window.setMember("setvar", new Boolean(false));
|
---|
587 | }
|
---|
588 |
|
---|
589 | public void jjsSetStringTest() {
|
---|
590 | window.setMember("setvar", "ð ã£$Ç£â¬ð");
|
---|
591 | }
|
---|
592 |
|
---|
593 | public void jjsSetObjectTest() {
|
---|
594 | dummyObject = new DummyObject("DummyObject2");
|
---|
595 | window.setMember("setvar", dummyObject);
|
---|
596 | }
|
---|
597 |
|
---|
598 | public void jjsSet1DArrayTest() {
|
---|
599 | ((JSObject) window.getMember("setvar")).setSlot(1, 100);
|
---|
600 | }
|
---|
601 |
|
---|
602 | public void jjsSet2DArrayTest() {
|
---|
603 | ((JSObject) ((JSObject) window.getMember("setvar")).getSlot(1)).setSlot(2, 200);
|
---|
604 | }
|
---|
605 |
|
---|
606 | /*
|
---|
607 | ****************************************
|
---|
608 | * Java -> JS call parameter conversion *
|
---|
609 | ****************************************
|
---|
610 | */
|
---|
611 |
|
---|
612 | public String jjsCallParamTest(String type) {
|
---|
613 |
|
---|
614 | Object ret = new Object();
|
---|
615 |
|
---|
616 | int i = 1;
|
---|
617 | double d = 1.1;
|
---|
618 | float f = 1.2F;
|
---|
619 | long l = 4294967296L;
|
---|
620 | short s = 2;
|
---|
621 | byte b = 3;
|
---|
622 | char c = '\u2323';
|
---|
623 | boolean bl = true;
|
---|
624 | Integer I = 4;
|
---|
625 | Double D = 4.1;
|
---|
626 | Float F = 4.2F;
|
---|
627 | Long L = 4294967297L;
|
---|
628 | Short S = 5;
|
---|
629 | Byte B = 6;
|
---|
630 | Boolean Bl = false;
|
---|
631 | Character C = '\u2324';
|
---|
632 | String str = "ð ã£$Ç£â¬ð";
|
---|
633 | Object o = new DummyObject("d1");
|
---|
634 |
|
---|
635 | String callParamTestFuncName = "JJSParameterTypeCallTest";
|
---|
636 |
|
---|
637 | if (type.equals("int"))
|
---|
638 | ret = window.call(callParamTestFuncName, new Object[]{i});
|
---|
639 | else if (type.equals("double"))
|
---|
640 | ret = window.call(callParamTestFuncName, new Object[]{d});
|
---|
641 | else if (type.equals("float"))
|
---|
642 | ret = window.call(callParamTestFuncName, new Object[]{f});
|
---|
643 | else if (type.equals("long"))
|
---|
644 | ret = window.call(callParamTestFuncName, new Object[]{l});
|
---|
645 | else if (type.equals("short"))
|
---|
646 | ret = window.call(callParamTestFuncName, new Object[]{s});
|
---|
647 | else if (type.equals("byte"))
|
---|
648 | ret = window.call(callParamTestFuncName, new Object[]{b});
|
---|
649 | else if (type.equals("char"))
|
---|
650 | ret = window.call(callParamTestFuncName, new Object[]{c});
|
---|
651 | else if (type.equals("boolean"))
|
---|
652 | ret = window.call(callParamTestFuncName, new Object[]{bl});
|
---|
653 | else if (type.equals("java.lang.Integer"))
|
---|
654 | ret = window.call(callParamTestFuncName, new Object[]{I});
|
---|
655 | else if (type.equals("java.lang.Double"))
|
---|
656 | ret = window.call(callParamTestFuncName, new Object[]{D});
|
---|
657 | else if (type.equals("java.lang.Float"))
|
---|
658 | ret = window.call(callParamTestFuncName, new Object[]{F});
|
---|
659 | else if (type.equals("java.lang.Long"))
|
---|
660 | ret = window.call(callParamTestFuncName, new Object[]{L});
|
---|
661 | else if (type.equals("java.lang.Short"))
|
---|
662 | ret = window.call(callParamTestFuncName, new Object[]{S});
|
---|
663 | else if (type.equals("java.lang.Byte"))
|
---|
664 | ret = window.call(callParamTestFuncName, new Object[]{B});
|
---|
665 | else if (type.equals("java.lang.Boolean"))
|
---|
666 | ret = window.call(callParamTestFuncName, new Object[]{Bl});
|
---|
667 | else if (type.equals("java.lang.Character"))
|
---|
668 | ret = window.call(callParamTestFuncName, new Object[]{C});
|
---|
669 | else if (type.equals("java.lang.String"))
|
---|
670 | ret = window.call(callParamTestFuncName, new Object[]{str});
|
---|
671 | else if (type.equals("PluginTest.Packages.DummyObject"))
|
---|
672 | ret = window.call(callParamTestFuncName, new Object[]{o});
|
---|
673 | else
|
---|
674 | ret = "Unknown param type: " + type;
|
---|
675 |
|
---|
676 | return ret.toString();
|
---|
677 | }
|
---|
678 |
|
---|
679 | /*
|
---|
680 | *******************************************
|
---|
681 | * Java -> JS invocation return type tests *
|
---|
682 | *******************************************
|
---|
683 | */
|
---|
684 |
|
---|
685 | public String jjsReturnTypeTest(String type) {
|
---|
686 |
|
---|
687 | String returnTypeTestFuncName = "JJSReturnTypeCallTest";
|
---|
688 | Object ret = window.call(returnTypeTestFuncName, new Object[]{type});
|
---|
689 |
|
---|
690 | return ret.toString();
|
---|
691 | }
|
---|
692 |
|
---|
693 |
|
---|
694 | /*
|
---|
695 | ***********************************
|
---|
696 | * Java -> JS invocation eval test *
|
---|
697 | ***********************************
|
---|
698 | */
|
---|
699 |
|
---|
700 | public String jjsEvalTest(String str) {
|
---|
701 | return window.eval(str).toString();
|
---|
702 | }
|
---|
703 |
|
---|
704 | public void init() {
|
---|
705 | window = JSObject.getWindow(this);
|
---|
706 | //JSObject.getWindow(this).call("appletLoaded", new Object[]{});
|
---|
707 | }
|
---|
708 |
|
---|
709 | }
|
---|
710 |
|
---|